Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-08-06 03:41:13
Exec Total Coverage
Lines: 1640 4177 39.3%
Functions: 129 329 39.2%
Branches: 881 2710 32.5%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // ZQuest Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for ZQuest Classic.
9 //
10 //--------------------------------------------------------
11
12 #include "zc/zc_sys.h"
13
14 #include "base/qrs.h"
15 #include "base/dmap.h"
16 #include <stdio.h>
17
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 #include <stdlib.h>
18 #include <string.h>
19 #include <math.h>
20 #include <map>
21 #include <filesystem>
22 #include <ctype.h>
23 #include <sstream>
24 #include "base/zc_alleg.h"
25 #include "gamedata.h"
26 #include "zc/zc_init.h"
27 #include "init.h"
28 #include "zc/replay.h"
29 #include "zc/cheats.h"
30 #include "zc/render.h"
31 #include "base/zc_math.h"
32 #include "base/zapp.h"
33 #include "dialog/cheatkeys.h"
34 #include "metadata/metadata.h"
35 #include "zc/zelda.h"
36 #include "tiles.h"
37 #include "base/colors.h"
38 #include "pal.h"
39 #include "base/zsys.h"
40 #include "qst.h"
41 #include "zc/zc_sys.h"
42 #include "play_midi.h"
43 #include "jwin_a5.h"
44 #include "base/jwinfsel.h"
45 #include "base/gui.h"
46 #include "midi.h"
47 #include "subscr.h"
48 #include "zc/maps.h"
49 #include "sprite.h"
50 #include "zc/guys.h"
51 #include "zc/hero.h"
52 #include "zc/title.h"
53 #include "particles.h"
54 #include "zcmusic.h"
55 #include "zconsole.h"
56 #include "zc/ffscript.h"
57 #include "dialog/info.h"
58 #include "dialog/alert.h"
59 #include "zc/combos.h"
60 #include "zc/jit.h"
61 #include <fmt/format.h>
62 #include "zinfo.h"
63 #include "base/misctypes.h"
64
65 #ifdef __EMSCRIPTEN__
66 #include "base/emscripten_utils.h"
67 #endif
68
69 extern FFScript FFCore;
70 extern bool Playing;
71 int32_t sfx_voice[WAV_COUNT];
72 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
73 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
74
75 extern byte monochrome_console;
76
77 extern HeroClass Hero;
78 extern FFScript FFCore;
79 extern ZModule zcm;
80 extern zcmodule moduledata;
81 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
82 extern particle_list particles;
83 extern int32_t loadlast;
84 extern char *sfx_string[WAV_COUNT];
85 byte use_dwm_flush;
86 byte use_save_indicator;
87 int32_t paused_midi_pos = 0;
88 byte midi_suspended = 0;
89 byte zc_192b163_warp_compatibility;
90 char modulepath[2048];
91 bool epilepsyFlashReduction;
92 signed char pause_in_background_menu_init = 0;
93 byte pause_in_background = 0;
94 bool is_sys_pal = false;
95 static bool load_control_called_this_frame;
96 extern PALETTE* hw_palette;
97 extern bool update_hw_pal;
98 extern const char* dmaplist(int32_t index, int32_t* list_size);
99 int32_t getnumber(const char *prompt,int32_t initialval);
100
101 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
102 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
103 //extern byte refresh_select_screen;
104 //extern movingblock mblock2; //mblock[4]?
105 //extern int32_t db;
106
107 static const char *ZC_str = "ZQuest Classic";
108 #if defined(ALLEGRO_WINDOWS)
109 const char *qst_dir_name = "win_qst_dir";
110 static const char *qst_module_name = "current_module";
111 #elif defined(ALLEGRO_LINUX)
112 const char *qst_dir_name = "linux_qst_dir";
113 static const char *qst_module_name = "current_module";
114 #elif defined(__APPLE__)
115 const char *qst_dir_name = "osx_qst_dir";
116 static const char *qst_module_name = "current_module";
117 #endif
118 #ifdef ALLEGRO_LINUX
119 static const char *samplepath = "samplesoundset/patches.dat";
120 #endif
121 char qst_files_path[2048];
122
123 #ifdef _MSC_VER
124 #define getcwd _getcwd
125 #endif
126
127 bool rF11();
128 bool rI();
129 bool rQ();
130 bool zc_key_pressed();
131
132 #ifdef _WIN32
133
134 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
135 extern "C"
136 {
137 typedef HRESULT(WINAPI *t_DwmFlush)();
138 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
139 }
140
141 void do_DwmFlush()
142 {
143 static HMODULE shell = LoadLibrary("dwmapi.dll");
144
145 if(!shell)
146 return;
147
148 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
149 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
150
151 BOOL enabled;
152 isEnabled(&enabled);
153
154 if(isEnabled)
155 flush();
156 }
157
158 #endif // _WIN32
159
160 83751 bool flash_reduction_enabled(bool check_qr)
161 {
162
4/4
✓ Branch 0 taken 81530 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 81074 times.
✓ Branch 3 taken 83295 times.
83751 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
163 }
164
165 // Dialogue largening
166 void large_dialog(DIALOG *d)
167 {
168 large_dialog(d, 1.5);
169 }
170
171 void large_dialog(DIALOG *d, float RESIZE_AMT)
172 {
173 if(!d[0].d1)
174 {
175 d[0].d1 = 1;
176 int32_t oldwidth = d[0].w;
177 int32_t oldheight = d[0].h;
178 int32_t oldx = d[0].x;
179 int32_t oldy = d[0].y;
180 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
181 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
182 d[0].w = int32_t(d[0].w*RESIZE_AMT);
183 d[0].h = int32_t(d[0].h*RESIZE_AMT);
184
185 for(int32_t i=1; d[i].proc !=NULL; i++)
186 {
187 // Place elements horizontally
188 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
189 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
190
191 if(d[i].proc != d_stringloader)
192 {
193 if(d[i].proc==d_bitmap_proc)
194 {
195 d[i].w *= 2;
196 }
197 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
198 }
199
200 // Place elements vertically
201 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
202 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
203
204 // Vertically resize elements
205 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
206 {
207 d[i].h = int32_t((double)d[i].h*1.5);
208 }
209 else if(d[i].proc == jwin_droplist_proc)
210 {
211 d[i].y += int32_t((double)d[i].h*0.25);
212 d[i].h = int32_t((double)d[i].h*1.25);
213 }
214 else if(d[i].proc==d_bitmap_proc)
215 {
216 d[i].h *= 2;
217 }
218 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
219
220 // Fix frames
221 if(d[i].proc == jwin_frame_proc)
222 {
223 d[i].x++;
224 d[i].y++;
225 d[i].w-=4;
226 d[i].h-=4;
227 }
228 }
229 }
230
231 for(int32_t i=1; d[i].proc!=NULL; i++)
232 {
233 if(d[i].proc==jwin_slider_proc)
234 continue;
235
236 // Bigger font
237 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
238
239 if(!d[i].dp2 && bigfontproc)
240 {
241 d[i].dp2 = get_zc_font(font_lfont_l);
242 }
243 else if(!bigfontproc)
244 {
245 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
246 }
247
248 // Make checkboxes work
249 if(d[i].proc == jwin_check_proc)
250 d[i].proc = jwin_checkfont_proc;
251 else if(d[i].proc == jwin_radio_proc)
252 d[i].proc = jwin_radiofont_proc;
253 }
254
255 jwin_center_dialog(d);
256 }
257
258
259 /**********************************/
260 /******** System functions ********/
261 /**********************************/
262
263 static char cfg_sect[] = "zeldadx"; //We need to rename this.
264 static char ctrl_sect[] = "Controls";
265 static char sfx_sect[] = "Volume";
266
267 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
268 {
269 return D_O_K;
270 }
271
272 bool is_reserved_key(int c)
273 {
274 switch(c)
275 {
276 case KEY_ESC:
277 return true;
278 }
279 return false;
280 }
281 bool is_reserved_keycombo(int c, int modflag)
282 {
283 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
284 return true;
285 return false;
286 }
287 bool checkcheat(Cheat cheat)
288 {
289 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
290 return true; //Main key pressed
291 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
292 return true; //Alt key pressed
293 return false;
294 }
295 45 void load_default_cheatkeys()
296 {
297 45 memset(cheatkeys, 0, sizeof(cheatkeys));
298 45 cheatkeys[Cheat::Life][0] = KEY_H;
299 45 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
300 45 cheatkeys[Cheat::Magic][0] = KEY_M;
301 45 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
302 45 cheatkeys[Cheat::Rupies][0] = KEY_R;
303 45 cheatkeys[Cheat::Bombs][0] = KEY_B;
304 45 cheatkeys[Cheat::Arrows][0] = KEY_A;
305 45 cheatkeys[Cheat::Clock][0] = KEY_I;
306 45 cheatkeys[Cheat::Walls][0] = KEY_F11;
307 45 cheatkeys[Cheat::Fast][0] = KEY_Q;
308 45 cheatkeys[Cheat::Light][0] = KEY_L;
309 45 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
310 45 cheatkeys[Cheat::Kill][0] = KEY_K;
311 45 cheatkeys[Cheat::GoTo][0] = KEY_G;
312 45 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
313 45 cheatkeys[Cheat::ShowL0][0] = KEY_0;
314 45 cheatkeys[Cheat::ShowL1][0] = KEY_1;
315 45 cheatkeys[Cheat::ShowL2][0] = KEY_2;
316 45 cheatkeys[Cheat::ShowL3][0] = KEY_3;
317 45 cheatkeys[Cheat::ShowL4][0] = KEY_4;
318 45 cheatkeys[Cheat::ShowL5][0] = KEY_5;
319 45 cheatkeys[Cheat::ShowL6][0] = KEY_6;
320 45 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
321 45 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
322 45 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
323 45 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
324 45 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
325 45 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
326 45 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
327 45 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
328 45 }
329 45 void load_game_configs()
330 {
331 45 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
332 45 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
333 45 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
334 45 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
335 45 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
336 45 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
337 45 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
338 45 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
339 45 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
340 45 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
341 45 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
342 45 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
343 45 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
344 45 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
345 45 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
346
347 //cheat modifier keya
348 45 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
349 45 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
350 45 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
351 45 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
352
353 //cheat keys
354 45 load_default_cheatkeys();
355 char buf[256];
356
2/2
✓ Branch 0 taken 1575 times.
✓ Branch 1 taken 45 times.
1620 for(size_t q = 1; q < Cheat::Last; ++q)
357 {
358
1/2
✓ Branch 0 taken 1575 times.
✗ Branch 1 not taken.
1575 if(!bindable_cheat((Cheat)q)) continue;
359 1575 std::string cheatname = cheat_to_string((Cheat)q);
360
1/2
✓ Branch 0 taken 1575 times.
✗ Branch 1 not taken.
1575 util::lowerstr(cheatname);
361 1575 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
362
1/2
✓ Branch 0 taken 1575 times.
✗ Branch 1 not taken.
1575 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
363 1575 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
364
1/2
✓ Branch 0 taken 1575 times.
✗ Branch 1 not taken.
1575 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
365 1575 }
366
367
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
368 joystick_index = 0;
369
370 45 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
371 45 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
372 45 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
373 45 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
374 45 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
375 45 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
376 45 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
377 45 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
378 45 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
379 45 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
380
381 45 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
382 45 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
383 45 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
384 45 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
385
386 45 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
387 45 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
388 45 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
389 45 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
390 45 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
391 45 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
392 45 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
393 45 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
394 45 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
395 45 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
396 45 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
397
398 45 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
399 45 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
400 45 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
401 45 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
402
403 45 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
404
405 45 digi_volume = zc_get_config(sfx_sect,"digi",248);
406 45 midi_volume = zc_get_config(sfx_sect,"midi",255);
407 45 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
408 45 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
409 45 pan_style = zc_get_config(sfx_sect,"pan",1);
410 // 1 <= zcmusic_bufsz <= 128
411 45 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
412 45 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
413 45 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
414 45 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
415 45 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
416 45 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
417 45 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
418 #ifdef __EMSCRIPTEN__
419 if (em_is_mobile()) NameEntryMode = 2;
420 #endif
421 45 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
422 45 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
423 45 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
424 45 title_version = zc_get_config(cfg_sect,"title",2);
425 45 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
426 45 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
427
428 //default - scale x2, 640 x 480
429 45 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
430 45 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
431 45 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
432 45 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
433 45 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
434 45 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
435 45 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
436
437 45 loadlast = zc_get_config(cfg_sect,"load_last",0);
438
439 45 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
440
441 45 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
442
443 45 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
444 45 info_opacity = zc_get_config("zc","debug_info_opacity",255);
445 #ifdef _WIN32
446 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
447 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
448 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
449 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
450
451 // This one's for Aero
452 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
453
454 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
455 #else //UNIX
456 45 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
457 45 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
458 45 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
459 #endif
460 45 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
461 45 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
462
463 45 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
464
465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(strlen(qstdir)==0)
466 {
467 45 getcwd(qstdir,2048);
468 45 fix_filename_case(qstdir);
469 45 fix_filename_slashes(qstdir);
470 45 put_backslash(qstdir);
471 45 }
472 else
473 {
474 chop_path(qstdir);
475 }
476
477 45 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
478 45 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
479 45 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
480 45 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
481 45 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
482 45 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
483 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
484 45 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
485 45 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
486 45 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
487 45 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
488 45 }
489
490 void save_control_configs(bool kb)
491 {
492 if(kb)
493 {
494 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
495 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
496 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
497 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
498
499 if (!replay_is_replaying())
500 {
501 zc_set_config(ctrl_sect,"key_a",Akey);
502 zc_set_config(ctrl_sect,"key_b",Bkey);
503 zc_set_config(ctrl_sect,"key_s",Skey);
504 zc_set_config(ctrl_sect,"key_l",Lkey);
505 zc_set_config(ctrl_sect,"key_r",Rkey);
506 zc_set_config(ctrl_sect,"key_p",Pkey);
507 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
508 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
509 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
510 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
511 zc_set_config(ctrl_sect,"key_up", DUkey);
512 zc_set_config(ctrl_sect,"key_down", DDkey);
513 zc_set_config(ctrl_sect,"key_left", DLkey);
514 zc_set_config(ctrl_sect,"key_right",DRkey);
515 }
516 }
517 else
518 {
519 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
520 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
521 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
522 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
523 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
524 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
525 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
526 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
527 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
528 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
529 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
530 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
531 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
532 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
533
534 zc_set_config(ctrl_sect,"btn_a",Abtn);
535 zc_set_config(ctrl_sect,"btn_b",Bbtn);
536 zc_set_config(ctrl_sect,"btn_s",Sbtn);
537 zc_set_config(ctrl_sect,"btn_m",Mbtn);
538 zc_set_config(ctrl_sect,"btn_l",Lbtn);
539 zc_set_config(ctrl_sect,"btn_r",Rbtn);
540 zc_set_config(ctrl_sect,"btn_p",Pbtn);
541 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
542 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
543 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
544 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
545
546 zc_set_config(ctrl_sect,"btn_up",DUbtn);
547 zc_set_config(ctrl_sect,"btn_down",DDbtn);
548 zc_set_config(ctrl_sect,"btn_left",DLbtn);
549 zc_set_config(ctrl_sect,"btn_right",DRbtn);
550 }
551 }
552
553 void save_cheatkeys()
554 {
555 char buf[256];
556 for(size_t q = 1; q < Cheat::Last; ++q)
557 {
558 if(!bindable_cheat((Cheat)q)) continue;
559 std::string cheatname = cheat_to_string((Cheat)q);
560 util::lowerstr(cheatname);
561 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
562 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
563 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
564 if(cheatkeys[q][1])
565 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
566 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
567 }
568 }
569
570 void save_game_configs()
571 {
572 packfile_password("");
573
574 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
575
576 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
577 {
578 int o_window_x, o_window_y;
579 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
580 zc_set_config(cfg_sect,"window_x",o_window_x);
581 zc_set_config(cfg_sect,"window_y",o_window_y);
582 }
583
584 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
585 {
586 double monitor_scale = zc_get_monitor_scale();
587 window_width = al_get_display_width(all_get_display()) / monitor_scale;
588 window_height = al_get_display_height(all_get_display()) / monitor_scale;
589 zc_set_config(cfg_sect,"window_width",window_width);
590 zc_set_config(cfg_sect,"window_height",window_height);
591 }
592
593 zc_set_config(cfg_sect,"load_last",loadlast);
594 chop_path(qstdir);
595 zc_set_config(cfg_sect,qst_dir_name,qstdir);
596 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
597
598 flush_config_file();
599 #ifdef __EMSCRIPTEN__
600 em_sync_fs();
601 #endif
602 }
603
604 //----------------------------------------------------------------
605
606 // Timers
607
608 31233 void fps_callback()
609 {
610 31233 lastfps=framecnt;
611 31233 dword tempsecs = fps_secs;
612 31233 ++tempsecs;
613 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
614 31233 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
615 31233 ++fps_secs;
616 31233 framecnt=0;
617 31233 }
618
619 END_OF_FUNCTION(fps_callback)
620
621 45 int32_t Z_init_timers()
622 {
623 static bool didit = false;
624 const static char *err_str = "Couldn't allocate timer";
625 45 err_str = err_str; //Unused variable warning
626
627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(didit)
628 return 1;
629
630 45 didit = true;
631
632 LOCK_VARIABLE(lastfps);
633 LOCK_VARIABLE(framecnt);
634 LOCK_FUNCTION(fps_callback);
635
636
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
637 return 0;
638
639 45 return 1;
640 45 }
641
642 void Z_remove_timers()
643 {
644 remove_int(fps_callback);
645 }
646
647 //----------------------------------------------------------------
648
649 void go()
650 {
651 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
652 }
653
654 void comeback()
655 {
656 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
657 }
658
659 void dump_pal(BITMAP *dest)
660 {
661 for(int32_t i=0; i<256; i++)
662 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
663 }
664
665 //----------------------------------------------------------------
666
667 int game_mouse_index = ZCM_BLANK;
668 static bool system_mouse = false;
669 26 bool sys_mouse()
670 {
671 26 system_mouse = true;
672 26 return MouseSprite::set(ZCM_NORMAL);
673 }
674 553 bool game_mouse()
675 {
676 553 system_mouse = false;
677 553 return MouseSprite::set(game_mouse_index);
678 }
679 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
680 {
681 if(!bmp)
682 return;
683 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
684 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
685 if(bmp->w == scaledw && bmp->h == scaledh)
686 user_scale = false;
687 if(user_scale || sys_recolor)
688 {
689 if(!user_scale) scale = 1;
690 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
691 if(user_scale)
692 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
693 else
694 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
695 if(sys_recolor)
696 recolor_mouse(tmpbmp);
697 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
698 destroy_bitmap(tmpbmp);
699 }
700 else
701 {
702 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
703 }
704 }
705
706 //Handles converting the mouse sprite from the .dat file
707 void recolor_mouse(BITMAP* bmp)
708 {
709 for(int32_t x = 0; x < bmp->w; ++x)
710 {
711 for(int32_t y = 0; y < bmp->h; ++y)
712 {
713 int32_t color = getpixel(bmp, x, y);
714 switch(color)
715 {
716 case dvc(1):
717 color = jwin_pal[jcCURSORMISC];
718 break;
719 case dvc(2):
720 color = jwin_pal[jcCURSOROUTLINE];
721 break;
722 case dvc(3):
723 color = jwin_pal[jcCURSORLIGHT];
724 break;
725 case dvc(5):
726 color = jwin_pal[jcCURSORDARK];
727 break;
728 default:
729 continue;
730 }
731 putpixel(bmp, x, y, color);
732 }
733 }
734 }
735 void load_mouse()
736 {
737 enter_sys_pal();
738 MouseSprite::set(-1);
739 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
740 int32_t sz = 16*scale;
741 for(int32_t j = 0; j < 1; ++j)
742 {
743 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
744 if(zcmouse[j])
745 destroy_bitmap(zcmouse[j]);
746 zcmouse[j] = create_bitmap_ex(8,sz,sz);
747 clear_bitmap(zcmouse[j]);
748 clear_bitmap(tmpbmp);
749 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
750 recolor_mouse(tmpbmp);
751 if(sz!=16)
752 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
753 else
754 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
755 destroy_bitmap(tmpbmp);
756 }
757 if(!hw_palette) hw_palette = &RAMpal;
758 zc_set_palette(*hw_palette);
759
760 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
761 clear_bitmap(blankmouse);
762
763 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
764 MouseSprite::assign(ZCM_BLANK, blankmouse);
765 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
766
767 //Reload the mouse
768 if(system_mouse)
769 sys_mouse();
770 else game_mouse();
771
772 destroy_bitmap(blankmouse);
773 exit_sys_pal();
774 }
775
776 // sets the video mode and initializes the palette and mouse sprite
777 45 bool game_vid_mode(int32_t mode,int32_t wait)
778 {
779
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if (is_headless())
780 45 return true;
781
782 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
783 {
784 return false;
785 }
786
787 scrx = (resx-320)>>1;
788 scry = (resy-240)>>1;
789 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
790 zcmouse[q] = NULL;
791 load_mouse();
792
793 for(int32_t i=240; i<256; i++)
794 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
795
796 zc_set_palette(RAMpal);
797 clear_to_color(screen,BLACK);
798
799 rest(wait);
800 return true;
801 45 }
802
803 8 void null_quest()
804 {
805 char qstdat_string[2048];
806 8 strcpy(qstdat_string, "modules/classic/default.qst");
807
808 #ifdef __EMSCRIPTEN__
809 // The quest template data file is not included because it's really big and isn't really needed
810 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
811 // which is much smaller.
812 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
813 #endif
814
815 8 byte skip_flags[4] = { 0 };
816
817 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
818 8 }
819
820 8 void init_NES_mode()
821 {
822 8 null_quest();
823 8 }
824
825 //----------------------------------------------------------------
826
827 qword trianglelines[16]=
828 {
829 0x0000000000000000ULL,
830 0xFD00000000000000ULL,
831 0xFDFD000000000000ULL,
832 0xFDFDFD0000000000ULL,
833 0xFDFDFDFD00000000ULL,
834 0xFDFDFDFDFD000000ULL,
835 0xFDFDFDFDFDFD0000ULL,
836 0xFDFDFDFDFDFDFD00ULL,
837 0xFDFDFDFDFDFDFDFDULL,
838 0x00FDFDFDFDFDFDFDULL,
839 0x0000FDFDFDFDFDFDULL,
840 0x000000FDFDFDFDFDULL,
841 0x00000000FDFDFDFDULL,
842 0x0000000000FDFDFDULL,
843 0x000000000000FDFDULL,
844 0x00000000000000FDULL,
845 };
846
847 word screen_triangles[28][32];
848 /*
849 qword triangles[4][16]= //[direction][value]
850 {
851 {
852 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
853 },
854 {
855 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
856 },
857 {
858 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
859 },
860 {
861 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
862 }
863 };
864 */
865
866
867 /*
868 byte triangles[4][16][8]= //[direction][value][line]
869 {
870 {
871 {
872 0, 0, 0, 0, 0, 0, 0, 0
873 },
874 {
875 1, 0, 0, 0, 0, 0, 0, 0
876 },
877 {
878 2, 1, 0, 0, 0, 0, 0, 0
879 },
880 {
881 3, 2, 1, 0, 0, 0, 0, 0
882 },
883 {
884 4, 3, 2, 1, 0, 0, 0, 0
885 },
886 {
887 5, 4, 3, 2, 1, 0, 0, 0
888 },
889 {
890 6, 5, 4, 3, 2, 1, 0, 0
891 },
892 {
893 7, 6, 5, 4, 3, 2, 1, 0
894 },
895 {
896 8, 7, 6, 5, 4, 3, 2, 1
897 },
898 {
899 8, 8, 7, 6, 5, 4, 3, 2
900 },
901 {
902 8, 8, 8, 7, 6, 5, 4, 3
903 },
904 {
905 8, 8, 8, 8, 7, 6, 5, 4
906 },
907 {
908 8, 8, 8, 8, 8, 7, 6, 5
909 },
910 {
911 8, 8, 8, 8, 8, 8, 7, 6
912 },
913 {
914 8, 8, 8, 8, 8, 8, 8, 7
915 },
916 {
917 8, 8, 8, 8, 8, 8, 8, 8
918 }
919 },
920 {
921 {
922 0, 0, 0, 0, 0, 0, 0, 0
923 },
924 {
925 15, 0, 0, 0, 0, 0, 0, 0
926 },
927 {
928 14, 15, 0, 0, 0, 0, 0, 0
929 },
930 {
931 13, 14, 15, 0, 0, 0, 0, 0
932 },
933 {
934 12, 13, 14, 15, 0, 0, 0, 0
935 },
936 {
937 11, 12, 13, 14, 15, 0, 0, 0
938 },
939 {
940 10, 11, 12, 13, 14, 15, 0, 0
941 },
942 {
943 9, 10, 11, 12, 13, 14, 15, 0
944 },
945 {
946 8, 9, 10, 11, 12, 13, 14, 15
947 },
948 {
949 8, 8, 9, 10, 11, 12, 13, 14
950 },
951 {
952 8, 8, 8, 9, 10, 11, 12, 13
953 },
954 {
955 8, 8, 8, 8, 9, 10, 11, 12
956 },
957 {
958 8, 8, 8, 8, 8, 9, 10, 11
959 },
960 {
961 8, 8, 8, 8, 8, 8, 9, 10
962 },
963 {
964 8, 8, 8, 8, 8, 8, 8, 9
965 },
966 {
967 8, 8, 8, 8, 8, 8, 8, 8
968 }
969 },
970 {
971 {
972 0, 0, 0, 0, 0, 0, 0, 0
973 },
974 {
975 0, 0, 0, 0, 0, 0, 0, 1
976 },
977 {
978 0, 0, 0, 0, 0, 0, 1, 2
979 },
980 {
981 0, 0, 0, 0, 0, 1, 2, 3
982 },
983 {
984 0, 0, 0, 0, 1, 2, 3, 4
985 },
986 {
987 0, 0, 0, 1, 2, 3, 4, 5
988 },
989 {
990 0, 0, 1, 2, 3, 4, 5, 6
991 },
992 {
993 0, 1, 2, 3, 4, 5, 6, 7
994 },
995 {
996 1, 2, 3, 4, 5, 6, 7, 8
997 },
998 {
999 2, 3, 4, 5, 6, 7, 8, 8
1000 },
1001 {
1002 3, 4, 5, 6, 7, 8, 8, 8
1003 },
1004 {
1005 4, 5, 6, 7, 8, 8, 8, 8
1006 },
1007 {
1008 5, 6, 7, 8, 8, 8, 8, 8
1009 },
1010 {
1011 6, 7, 8, 8, 8, 8, 8, 8
1012 },
1013 {
1014 7, 8, 8, 8, 8, 8, 8, 8
1015 },
1016 {
1017 8, 8, 8, 8, 8, 8, 8, 8
1018 }
1019 },
1020 {
1021 {
1022 0, 0, 0, 0, 0, 0, 0, 0
1023 },
1024 {
1025 0, 0, 0, 0, 0, 0, 0, 15
1026 },
1027 {
1028 0, 0, 0, 0, 0, 0, 15, 14
1029 },
1030 {
1031 0, 0, 0, 0, 0, 15, 14, 13
1032 },
1033 {
1034 0, 0, 0, 0, 15, 14, 13, 12
1035 },
1036 {
1037 0, 0, 0, 15, 14, 13, 12, 11
1038 },
1039 {
1040 0, 0, 15, 14, 13, 12, 11, 10
1041 },
1042 {
1043 0, 15, 14, 13, 12, 11, 10, 9
1044 },
1045 {
1046 15, 14, 13, 12, 11, 10, 9, 8
1047 },
1048 {
1049 14, 13, 12, 11, 10, 9, 8, 8
1050 },
1051 {
1052 13, 12, 11, 10, 9, 8, 8, 8
1053 },
1054 {
1055 12, 11, 10, 9, 8, 8, 8, 8
1056 },
1057 {
1058 11, 10, 9, 8, 8, 8, 8, 8
1059 },
1060 {
1061 10, 9, 8, 8, 8, 8, 8, 8
1062 },
1063 {
1064 9, 8, 8, 8, 8, 8, 8, 8
1065 },
1066 {
1067 8, 8, 8, 8, 8, 8, 8, 8
1068 }
1069 }
1070 };
1071 */
1072
1073
1074
1075 /*
1076 for (int32_t blockrow=0; blockrow<30; ++i)
1077 {
1078 for (int32_t linerow=0; linerow<8; ++i)
1079 {
1080 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1081 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1082 {
1083 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1084 ++triangleline;
1085 }
1086 }
1087 }
1088 */
1089
1090 // the ULL suffixes are to prevent this warning:
1091 // warning: integer constant is too large for "int32_t" type
1092
1093 qword triangles[4][16][8]= //[direction][value][line]
1094 {
1095 {
1096 {
1097 0x0000000000000000ULL,
1098 0x0000000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL
1105 },
1106 {
1107 0xFD00000000000000ULL,
1108 0x0000000000000000ULL,
1109 0x0000000000000000ULL,
1110 0x0000000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL
1115 },
1116 {
1117 0xFDFD000000000000ULL,
1118 0xFD00000000000000ULL,
1119 0x0000000000000000ULL,
1120 0x0000000000000000ULL,
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL
1125 },
1126 {
1127 0xFDFDFD0000000000ULL,
1128 0xFDFD000000000000ULL,
1129 0xFD00000000000000ULL,
1130 0x0000000000000000ULL,
1131 0x0000000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL,
1134 0x0000000000000000ULL
1135 },
1136 {
1137 0xFDFDFDFD00000000ULL,
1138 0xFDFDFD0000000000ULL,
1139 0xFDFD000000000000ULL,
1140 0xFD00000000000000ULL,
1141 0x0000000000000000ULL,
1142 0x0000000000000000ULL,
1143 0x0000000000000000ULL,
1144 0x0000000000000000ULL
1145 },
1146 {
1147 0xFDFDFDFDFD000000ULL,
1148 0xFDFDFDFD00000000ULL,
1149 0xFDFDFD0000000000ULL,
1150 0xFDFD000000000000ULL,
1151 0xFD00000000000000ULL,
1152 0x0000000000000000ULL,
1153 0x0000000000000000ULL,
1154 0x0000000000000000ULL
1155 },
1156 {
1157 0xFDFDFDFDFDFD0000ULL,
1158 0xFDFDFDFDFD000000ULL,
1159 0xFDFDFDFD00000000ULL,
1160 0xFDFDFD0000000000ULL,
1161 0xFDFD000000000000ULL,
1162 0xFD00000000000000ULL,
1163 0x0000000000000000ULL,
1164 0x0000000000000000ULL
1165 },
1166 {
1167 0xFDFDFDFDFDFDFD00ULL,
1168 0xFDFDFDFDFDFD0000ULL,
1169 0xFDFDFDFDFD000000ULL,
1170 0xFDFDFDFD00000000ULL,
1171 0xFDFDFD0000000000ULL,
1172 0xFDFD000000000000ULL,
1173 0xFD00000000000000ULL,
1174 0x0000000000000000ULL
1175 },
1176 {
1177 0xFDFDFDFDFDFDFDFDULL,
1178 0xFDFDFDFDFDFDFD00ULL,
1179 0xFDFDFDFDFDFD0000ULL,
1180 0xFDFDFDFDFD000000ULL,
1181 0xFDFDFDFD00000000ULL,
1182 0xFDFDFD0000000000ULL,
1183 0xFDFD000000000000ULL,
1184 0xFD00000000000000ULL
1185 },
1186 {
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFD00ULL,
1190 0xFDFDFDFDFDFD0000ULL,
1191 0xFDFDFDFDFD000000ULL,
1192 0xFDFDFDFD00000000ULL,
1193 0xFDFDFD0000000000ULL,
1194 0xFDFD000000000000ULL
1195 },
1196 {
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFD00ULL,
1201 0xFDFDFDFDFDFD0000ULL,
1202 0xFDFDFDFDFD000000ULL,
1203 0xFDFDFDFD00000000ULL,
1204 0xFDFDFD0000000000ULL
1205 },
1206 {
1207 0xFDFDFDFDFDFDFDFDULL,
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFD00ULL,
1212 0xFDFDFDFDFDFD0000ULL,
1213 0xFDFDFDFDFD000000ULL,
1214 0xFDFDFDFD00000000ULL
1215 },
1216 {
1217 0xFDFDFDFDFDFDFDFDULL,
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFD00ULL,
1223 0xFDFDFDFDFDFD0000ULL,
1224 0xFDFDFDFDFD000000ULL
1225 },
1226 {
1227 0xFDFDFDFDFDFDFDFDULL,
1228 0xFDFDFDFDFDFDFDFDULL,
1229 0xFDFDFDFDFDFDFDFDULL,
1230 0xFDFDFDFDFDFDFDFDULL,
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0xFDFDFDFDFDFDFD00ULL,
1234 0xFDFDFDFDFDFD0000ULL
1235 },
1236 {
1237 0xFDFDFDFDFDFDFDFDULL,
1238 0xFDFDFDFDFDFDFDFDULL,
1239 0xFDFDFDFDFDFDFDFDULL,
1240 0xFDFDFDFDFDFDFDFDULL,
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFD00ULL
1245 },
1246 {
1247 0xFDFDFDFDFDFDFDFDULL,
1248 0xFDFDFDFDFDFDFDFDULL,
1249 0xFDFDFDFDFDFDFDFDULL,
1250 0xFDFDFDFDFDFDFDFDULL,
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL
1255 }
1256 },
1257 {
1258 {
1259 0x0000000000000000ULL,
1260 0x0000000000000000ULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL
1267 },
1268 {
1269 0x00000000000000FDULL,
1270 0x0000000000000000ULL,
1271 0x0000000000000000ULL,
1272 0x0000000000000000ULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL
1277 },
1278 {
1279 0x000000000000FDFDULL,
1280 0x00000000000000FDULL,
1281 0x0000000000000000ULL,
1282 0x0000000000000000ULL,
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL
1287 },
1288 {
1289 0x0000000000FDFDFDULL,
1290 0x000000000000FDFDULL,
1291 0x00000000000000FDULL,
1292 0x0000000000000000ULL,
1293 0x0000000000000000ULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL,
1296 0x0000000000000000ULL
1297 },
1298 {
1299 0x00000000FDFDFDFDULL,
1300 0x0000000000FDFDFDULL,
1301 0x000000000000FDFDULL,
1302 0x00000000000000FDULL,
1303 0x0000000000000000ULL,
1304 0x0000000000000000ULL,
1305 0x0000000000000000ULL,
1306 0x0000000000000000ULL
1307 },
1308 {
1309 0x000000FDFDFDFDFDULL,
1310 0x00000000FDFDFDFDULL,
1311 0x0000000000FDFDFDULL,
1312 0x000000000000FDFDULL,
1313 0x00000000000000FDULL,
1314 0x0000000000000000ULL,
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL
1317 },
1318 {
1319 0x0000FDFDFDFDFDFDULL,
1320 0x000000FDFDFDFDFDULL,
1321 0x00000000FDFDFDFDULL,
1322 0x0000000000FDFDFDULL,
1323 0x000000000000FDFDULL,
1324 0x00000000000000FDULL,
1325 0x0000000000000000ULL,
1326 0x0000000000000000ULL
1327 },
1328 {
1329 0x00FDFDFDFDFDFDFDULL,
1330 0x0000FDFDFDFDFDFDULL,
1331 0x000000FDFDFDFDFDULL,
1332 0x00000000FDFDFDFDULL,
1333 0x0000000000FDFDFDULL,
1334 0x000000000000FDFDULL,
1335 0x00000000000000FDULL,
1336 0x0000000000000000ULL
1337 },
1338 {
1339 0xFDFDFDFDFDFDFDFDULL,
1340 0x00FDFDFDFDFDFDFDULL,
1341 0x0000FDFDFDFDFDFDULL,
1342 0x000000FDFDFDFDFDULL,
1343 0x00000000FDFDFDFDULL,
1344 0x0000000000FDFDFDULL,
1345 0x000000000000FDFDULL,
1346 0x00000000000000FDULL
1347 },
1348 {
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0x00FDFDFDFDFDFDFDULL,
1352 0x0000FDFDFDFDFDFDULL,
1353 0x000000FDFDFDFDFDULL,
1354 0x00000000FDFDFDFDULL,
1355 0x0000000000FDFDFDULL,
1356 0x000000000000FDFDULL
1357 },
1358 {
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0x00FDFDFDFDFDFDFDULL,
1363 0x0000FDFDFDFDFDFDULL,
1364 0x000000FDFDFDFDFDULL,
1365 0x00000000FDFDFDFDULL,
1366 0x0000000000FDFDFDULL
1367 },
1368 {
1369 0xFDFDFDFDFDFDFDFDULL,
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0x00FDFDFDFDFDFDFDULL,
1374 0x0000FDFDFDFDFDFDULL,
1375 0x000000FDFDFDFDFDULL,
1376 0x00000000FDFDFDFDULL
1377 },
1378 {
1379 0xFDFDFDFDFDFDFDFDULL,
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0x00FDFDFDFDFDFDFDULL,
1385 0x0000FDFDFDFDFDFDULL,
1386 0x000000FDFDFDFDFDULL
1387 },
1388 {
1389 0xFDFDFDFDFDFDFDFDULL,
1390 0xFDFDFDFDFDFDFDFDULL,
1391 0xFDFDFDFDFDFDFDFDULL,
1392 0xFDFDFDFDFDFDFDFDULL,
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0xFDFDFDFDFDFDFDFDULL,
1395 0x00FDFDFDFDFDFDFDULL,
1396 0x0000FDFDFDFDFDFDULL
1397 },
1398 {
1399 0xFDFDFDFDFDFDFDFDULL,
1400 0xFDFDFDFDFDFDFDFDULL,
1401 0xFDFDFDFDFDFDFDFDULL,
1402 0xFDFDFDFDFDFDFDFDULL,
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0xFDFDFDFDFDFDFDFDULL,
1406 0x00FDFDFDFDFDFDFDULL
1407 },
1408 {
1409 0xFDFDFDFDFDFDFDFDULL,
1410 0xFDFDFDFDFDFDFDFDULL,
1411 0xFDFDFDFDFDFDFDFDULL,
1412 0xFDFDFDFDFDFDFDFDULL,
1413 0xFDFDFDFDFDFDFDFDULL,
1414 0xFDFDFDFDFDFDFDFDULL,
1415 0xFDFDFDFDFDFDFDFDULL,
1416 0xFDFDFDFDFDFDFDFDULL
1417 }
1418 },
1419 {
1420 {
1421 0x0000000000000000ULL,
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL,
1428 0x0000000000000000ULL
1429 },
1430 {
1431 0x0000000000000000ULL,
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0x0000000000000000ULL,
1438 0xFD00000000000000ULL
1439 },
1440 {
1441 0x0000000000000000ULL,
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0x0000000000000000ULL,
1447 0xFD00000000000000ULL,
1448 0xFDFD000000000000ULL
1449 },
1450 {
1451 0x0000000000000000ULL,
1452 0x0000000000000000ULL,
1453 0x0000000000000000ULL,
1454 0x0000000000000000ULL,
1455 0x0000000000000000ULL,
1456 0xFD00000000000000ULL,
1457 0xFDFD000000000000ULL,
1458 0xFDFDFD0000000000ULL
1459 },
1460 {
1461 0x0000000000000000ULL,
1462 0x0000000000000000ULL,
1463 0x0000000000000000ULL,
1464 0x0000000000000000ULL,
1465 0xFD00000000000000ULL,
1466 0xFDFD000000000000ULL,
1467 0xFDFDFD0000000000ULL,
1468 0xFDFDFDFD00000000ULL
1469 },
1470 {
1471 0x0000000000000000ULL,
1472 0x0000000000000000ULL,
1473 0x0000000000000000ULL,
1474 0xFD00000000000000ULL,
1475 0xFDFD000000000000ULL,
1476 0xFDFDFD0000000000ULL,
1477 0xFDFDFDFD00000000ULL,
1478 0xFDFDFDFDFD000000ULL
1479 },
1480 {
1481 0x0000000000000000ULL,
1482 0x0000000000000000ULL,
1483 0xFD00000000000000ULL,
1484 0xFDFD000000000000ULL,
1485 0xFDFDFD0000000000ULL,
1486 0xFDFDFDFD00000000ULL,
1487 0xFDFDFDFDFD000000ULL,
1488 0xFDFDFDFDFDFD0000ULL
1489 },
1490 {
1491 0x0000000000000000ULL,
1492 0xFD00000000000000ULL,
1493 0xFDFD000000000000ULL,
1494 0xFDFDFD0000000000ULL,
1495 0xFDFDFDFD00000000ULL,
1496 0xFDFDFDFDFD000000ULL,
1497 0xFDFDFDFDFDFD0000ULL,
1498 0xFDFDFDFDFDFDFD00ULL
1499 },
1500 {
1501 0xFD00000000000000ULL,
1502 0xFDFD000000000000ULL,
1503 0xFDFDFD0000000000ULL,
1504 0xFDFDFDFD00000000ULL,
1505 0xFDFDFDFDFD000000ULL,
1506 0xFDFDFDFDFDFD0000ULL,
1507 0xFDFDFDFDFDFDFD00ULL,
1508 0xFDFDFDFDFDFDFDFDULL
1509 },
1510 {
1511 0xFDFD000000000000ULL,
1512 0xFDFDFD0000000000ULL,
1513 0xFDFDFDFD00000000ULL,
1514 0xFDFDFDFDFD000000ULL,
1515 0xFDFDFDFDFDFD0000ULL,
1516 0xFDFDFDFDFDFDFD00ULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL
1519 },
1520 {
1521 0xFDFDFD0000000000ULL,
1522 0xFDFDFDFD00000000ULL,
1523 0xFDFDFDFDFD000000ULL,
1524 0xFDFDFDFDFDFD0000ULL,
1525 0xFDFDFDFDFDFDFD00ULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL
1529 },
1530 {
1531 0xFDFDFDFD00000000ULL,
1532 0xFDFDFDFDFD000000ULL,
1533 0xFDFDFDFDFDFD0000ULL,
1534 0xFDFDFDFDFDFDFD00ULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL
1539 },
1540 {
1541 0xFDFDFDFDFD000000ULL,
1542 0xFDFDFDFDFDFD0000ULL,
1543 0xFDFDFDFDFDFDFD00ULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL
1549 },
1550 {
1551 0xFDFDFDFDFDFD0000ULL,
1552 0xFDFDFDFDFDFDFD00ULL,
1553 0xFDFDFDFDFDFDFDFDULL,
1554 0xFDFDFDFDFDFDFDFDULL,
1555 0xFDFDFDFDFDFDFDFDULL,
1556 0xFDFDFDFDFDFDFDFDULL,
1557 0xFDFDFDFDFDFDFDFDULL,
1558 0xFDFDFDFDFDFDFDFDULL
1559 },
1560 {
1561 0xFDFDFDFDFDFDFD00ULL,
1562 0xFDFDFDFDFDFDFDFDULL,
1563 0xFDFDFDFDFDFDFDFDULL,
1564 0xFDFDFDFDFDFDFDFDULL,
1565 0xFDFDFDFDFDFDFDFDULL,
1566 0xFDFDFDFDFDFDFDFDULL,
1567 0xFDFDFDFDFDFDFDFDULL,
1568 0xFDFDFDFDFDFDFDFDULL
1569 },
1570 {
1571 0xFDFDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL,
1574 0xFDFDFDFDFDFDFDFDULL,
1575 0xFDFDFDFDFDFDFDFDULL,
1576 0xFDFDFDFDFDFDFDFDULL,
1577 0xFDFDFDFDFDFDFDFDULL,
1578 0xFDFDFDFDFDFDFDFDULL
1579 }
1580 },
1581 {
1582 {
1583 0x0000000000000000ULL,
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL,
1590 0x0000000000000000ULL
1591 },
1592 {
1593 0x0000000000000000ULL,
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x0000000000000000ULL,
1600 0x00000000000000FDULL
1601 },
1602 {
1603 0x0000000000000000ULL,
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x0000000000000000ULL,
1609 0x00000000000000FDULL,
1610 0x000000000000FDFDULL
1611 },
1612 {
1613 0x0000000000000000ULL,
1614 0x0000000000000000ULL,
1615 0x0000000000000000ULL,
1616 0x0000000000000000ULL,
1617 0x0000000000000000ULL,
1618 0x00000000000000FDULL,
1619 0x000000000000FDFDULL,
1620 0x0000000000FDFDFDULL
1621 },
1622 {
1623 0x0000000000000000ULL,
1624 0x0000000000000000ULL,
1625 0x0000000000000000ULL,
1626 0x0000000000000000ULL,
1627 0x00000000000000FDULL,
1628 0x000000000000FDFDULL,
1629 0x0000000000FDFDFDULL,
1630 0x00000000FDFDFDFDULL
1631 },
1632 {
1633 0x0000000000000000ULL,
1634 0x0000000000000000ULL,
1635 0x0000000000000000ULL,
1636 0x00000000000000FDULL,
1637 0x000000000000FDFDULL,
1638 0x0000000000FDFDFDULL,
1639 0x00000000FDFDFDFDULL,
1640 0x000000FDFDFDFDFDULL
1641 },
1642 {
1643 0x0000000000000000ULL,
1644 0x0000000000000000ULL,
1645 0x00000000000000FDULL,
1646 0x000000000000FDFDULL,
1647 0x0000000000FDFDFDULL,
1648 0x00000000FDFDFDFDULL,
1649 0x000000FDFDFDFDFDULL,
1650 0x0000FDFDFDFDFDFDULL
1651 },
1652 {
1653 0x0000000000000000ULL,
1654 0x00000000000000FDULL,
1655 0x000000000000FDFDULL,
1656 0x0000000000FDFDFDULL,
1657 0x00000000FDFDFDFDULL,
1658 0x000000FDFDFDFDFDULL,
1659 0x0000FDFDFDFDFDFDULL,
1660 0x00FDFDFDFDFDFDFDULL
1661 },
1662 {
1663 0x00000000000000FDULL,
1664 0x000000000000FDFDULL,
1665 0x0000000000FDFDFDULL,
1666 0x00000000FDFDFDFDULL,
1667 0x000000FDFDFDFDFDULL,
1668 0x0000FDFDFDFDFDFDULL,
1669 0x00FDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL
1671 },
1672 {
1673 0x000000000000FDFDULL,
1674 0x0000000000FDFDFDULL,
1675 0x00000000FDFDFDFDULL,
1676 0x000000FDFDFDFDFDULL,
1677 0x0000FDFDFDFDFDFDULL,
1678 0x00FDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL
1681 },
1682 {
1683 0x0000000000FDFDFDULL,
1684 0x00000000FDFDFDFDULL,
1685 0x000000FDFDFDFDFDULL,
1686 0x0000FDFDFDFDFDFDULL,
1687 0x00FDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL
1691 },
1692 {
1693 0x00000000FDFDFDFDULL,
1694 0x000000FDFDFDFDFDULL,
1695 0x0000FDFDFDFDFDFDULL,
1696 0x00FDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL
1701 },
1702 {
1703 0x000000FDFDFDFDFDULL,
1704 0x0000FDFDFDFDFDFDULL,
1705 0x00FDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL
1711 },
1712 {
1713 0x0000FDFDFDFDFDFDULL,
1714 0x00FDFDFDFDFDFDFDULL,
1715 0xFDFDFDFDFDFDFDFDULL,
1716 0xFDFDFDFDFDFDFDFDULL,
1717 0xFDFDFDFDFDFDFDFDULL,
1718 0xFDFDFDFDFDFDFDFDULL,
1719 0xFDFDFDFDFDFDFDFDULL,
1720 0xFDFDFDFDFDFDFDFDULL
1721 },
1722 {
1723 0x00FDFDFDFDFDFDFDULL,
1724 0xFDFDFDFDFDFDFDFDULL,
1725 0xFDFDFDFDFDFDFDFDULL,
1726 0xFDFDFDFDFDFDFDFDULL,
1727 0xFDFDFDFDFDFDFDFDULL,
1728 0xFDFDFDFDFDFDFDFDULL,
1729 0xFDFDFDFDFDFDFDFDULL,
1730 0xFDFDFDFDFDFDFDFDULL
1731 },
1732 {
1733 0xFDFDFDFDFDFDFDFDULL,
1734 0xFDFDFDFDFDFDFDFDULL,
1735 0xFDFDFDFDFDFDFDFDULL,
1736 0xFDFDFDFDFDFDFDFDULL,
1737 0xFDFDFDFDFDFDFDFDULL,
1738 0xFDFDFDFDFDFDFDFDULL,
1739 0xFDFDFDFDFDFDFDFDULL,
1740 0xFDFDFDFDFDFDFDFDULL
1741 }
1742 }
1743 };
1744
1745 int32_t black_opening_count=0;
1746 int32_t black_opening_x,black_opening_y;
1747 int32_t black_opening_shape;
1748
1749 1505 int32_t choose_opening_shape()
1750 {
1751 // First, count how many bits are set
1752 1505 int32_t numBits=0;
1753 int32_t bitCounter;
1754
1755
2/2
✓ Branch 0 taken 7525 times.
✓ Branch 1 taken 1505 times.
9030 for(int32_t i=0; i<bosMAX; i++)
1756 {
1757
2/2
✓ Branch 0 taken 5804 times.
✓ Branch 1 taken 1721 times.
7525 if(COOLSCROLL&(1<<i))
1758 1721 numBits++;
1759 7525 }
1760
1761 // Shouldn't happen...
1762
1/2
✓ Branch 0 taken 1505 times.
✗ Branch 1 not taken.
1505 if(numBits==0)
1763 return bosCIRCLE;
1764
1765 // Pick a bit
1766 1505 bitCounter=zc_rand()%numBits+1;
1767
1768
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 26 times.
2016 for(int32_t i=0; i<bosMAX; i++)
1769 {
1770 // If this bit is set, decrement the bit counter
1771
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 1635 times.
1990 if(COOLSCROLL&(1<<i))
1772 1635 bitCounter--;
1773
1774 // When the counter hits 0, return a value based on
1775 // which bit it stopped on.
1776 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1777
2/2
✓ Branch 0 taken 1479 times.
✓ Branch 1 taken 511 times.
1990 if(bitCounter==0)
1778 1479 return i;
1779 511 }
1780
1781 // Shouldn't be necessary, but the compiler might complain, at least
1782 26 return bosCIRCLE;
1783 1505 }
1784
1785 396 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1786 {
1787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1788
1789 396 int32_t w=256, h=224;
1790 396 int32_t blockrows=28, blockcolumns=32;
1791 396 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1792
1793
2/2
✓ Branch 0 taken 11088 times.
✓ Branch 1 taken 396 times.
11484 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1794 {
1795
2/2
✓ Branch 0 taken 354816 times.
✓ Branch 1 taken 11088 times.
365904 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1796 {
1797
2/2
✓ Branch 0 taken 188540 times.
✓ Branch 1 taken 166276 times.
354816 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1798 354816 }
1799 11088 }
1800
1801 396 black_opening_count = 66;
1802 396 black_opening_x = x;
1803 396 black_opening_y = y;
1804 396 lensclk = 0;
1805 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1806
1807
1808
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(black_opening_shape == bosFADEBLACK)
1809 {
1810 refreshTints();
1811 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1812 }
1813
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(wait)
1814 {
1815 FFCore.warpScriptCheck();
1816 for(int32_t i=0; i<66; i++)
1817 {
1818 draw_screen(tmpscr);
1819 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1820 advanceframe(true);
1821
1822 if(Quit)
1823 {
1824 break;
1825 }
1826 }
1827 }
1828 396 }
1829
1830 1109 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1831 {
1832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1109 times.
1109 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1833
1834 1109 int32_t w=256, h=224;
1835 1109 int32_t blockrows=28, blockcolumns=32;
1836 1109 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1837
1838
2/2
✓ Branch 0 taken 31052 times.
✓ Branch 1 taken 1109 times.
32161 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1839 {
1840
2/2
✓ Branch 0 taken 993664 times.
✓ Branch 1 taken 31052 times.
1024716 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1841 {
1842
2/2
✓ Branch 0 taken 441809 times.
✓ Branch 1 taken 551855 times.
993664 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1843 993664 }
1844 31052 }
1845
1846 1109 black_opening_count = -66;
1847 1109 black_opening_x = x;
1848 1109 black_opening_y = y;
1849 1109 lensclk = 0;
1850
1/2
✓ Branch 0 taken 1109 times.
✗ Branch 1 not taken.
1109 if(black_opening_shape == bosFADEBLACK)
1851 {
1852 refreshTints();
1853 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1854 }
1855
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 910 times.
1109 if(wait)
1856 {
1857 910 FFCore.warpScriptCheck();
1858
2/2
✓ Branch 0 taken 910 times.
✓ Branch 1 taken 60060 times.
60970 for(int32_t i=0; i<66; i++)
1859 {
1860 60060 draw_screen(tmpscr);
1861 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1862 60060 advanceframe(true);
1863
1864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60060 times.
60060 if(Quit)
1865 {
1866 break;
1867 }
1868 60060 }
1869 910 }
1870 1109 }
1871
1872 99330 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1873 {
1874 99330 clear_to_color(tmp_scr,BLACK);
1875 99330 int32_t w=256, h=224;
1876
1877
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 7656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90156 times.
99330 switch(black_opening_shape)
1878 {
1879 case bosOVAL:
1880 {
1881 858 double new_w=(w/2)+abs(w/2-x);
1882 858 double new_h=(h/2)+abs(h/2-y);
1883 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1884 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1885 858 break;
1886 }
1887
1888 case bosTRIANGLE:
1889 {
1890 660 double new_w=(w/2)+abs(w/2-x);
1891 660 double new_h=(h/2)+abs(h/2-y);
1892 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1893 660 double P2= (PI/2);
1894 660 double P23=(2*PI/3);
1895 660 double P43=(4*PI/3);
1896 660 double Pa= (-4*PI*a/(3*max_a));
1897 660 double angle=P2+Pa;
1898 660 double a0=angle;
1899 660 double a2=angle+P23;
1900 660 double a4=angle+P43;
1901 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1902 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1903 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1904 0);
1905 660 break;
1906 }
1907
1908 case bosSMAS:
1909 {
1910
2/2
✓ Branch 0 taken 2838 times.
✓ Branch 1 taken 4818 times.
7656 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1911
1912
2/2
✓ Branch 0 taken 214368 times.
✓ Branch 1 taken 7656 times.
222024 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1913 {
1914
2/2
✓ Branch 0 taken 1714944 times.
✓ Branch 1 taken 214368 times.
1929312 for(int32_t linerow=0; linerow<8; ++linerow)
1915 {
1916 1714944 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1917
1918
2/2
✓ Branch 0 taken 54878208 times.
✓ Branch 1 taken 1714944 times.
56593152 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1919 {
1920 164634624 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1921
6/6
✓ Branch 0 taken 38180568 times.
✓ Branch 1 taken 16697640 times.
✓ Branch 2 taken 35934032 times.
✓ Branch 3 taken 18944176 times.
✓ Branch 4 taken 19236392 times.
✓ Branch 5 taken 16697640 times.
54878208 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1922 54878208 [linerow];
1923 54878208 ++triangleline;
1924
1925
2/2
✓ Branch 0 taken 48018432 times.
✓ Branch 1 taken 6859776 times.
54878208 if(linerow==0)
1926 {
1927 6859776 }
1928 54878208 }
1929 1714944 }
1930 214368 }
1931
1932 7656 break;
1933 }
1934
1935 case bosFADEBLACK:
1936 {
1937 if(black_opening_count<0)
1938 {
1939 black_fade(zc_min(-black_opening_count,63));
1940 }
1941 else if(black_opening_count>0)
1942 {
1943 black_fade(63-zc_max(black_opening_count-3,0));
1944 }
1945 else black_fade(0);
1946 return; //no blitting from tmp_scr!
1947 }
1948
1949 90156 case bosCIRCLE:
1950 default:
1951 {
1952 90156 double new_w=(w/2)+abs(w/2-x);
1953 90156 double new_h=(h/2)+abs(h/2-y);
1954 90156 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1955 //circlefill(tmp_scr,x,y,a<<3,0);
1956 90156 circlefill(tmp_scr,x,y,r,0);
1957 90156 break;
1958 }
1959 }
1960
1961 99330 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1962 99330 }
1963
1964
1965 void black_fade(int32_t fadeamnt)
1966 {
1967 for(int32_t i=0; i < 0xEF; i++)
1968 {
1969 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1970 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1971 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1972 }
1973
1974 refreshpal = true;
1975 }
1976
1977 //----------------------------------------------------------------
1978
1979 38804614 bool item_disabled(int32_t item) //is this item disabled?
1980 {
1981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38804614 times.
38804614 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1982 }
1983
1984 7615626 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1985 {
1986
2/2
✓ Branch 0 taken 135248 times.
✓ Branch 1 taken 7480378 times.
7615626 if(current_item(item_type, true) >=item)
1987 {
1988 135248 return true;
1989 }
1990
1991 7480378 return false;
1992 7615626 }
1993
1994 30661508 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1995 {
1996
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6051742 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3220277 times.
✓ Branch 6 taken 16010075 times.
✓ Branch 7 taken 5337675 times.
✓ Branch 8 taken 41739 times.
30661508 switch(item_type)
1997 {
1998 case itype_bomb:
1999 case itype_sbomb:
2000 {
2001 int32_t itemid = getItemID(itemsbuf, item_type, it);
2002
2003 if(itemid == -1)
2004 return false;
2005
2006 return (game->get_item(itemid));
2007 }
2008
2009 case itype_clock:
2010 {
2011 6051742 int32_t itemid = getItemID(itemsbuf, item_type, it);
2012
2013
2/4
✓ Branch 0 taken 6051742 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6051742 times.
✗ Branch 3 not taken.
6051742 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2014 return (game->get_item(itemid));
2015 6051742 return Hero.getClock()?1:0;
2016 }
2017
2018 case itype_key:
2019 return (game->get_keys()>0);
2020
2021 case itype_magiccontainer:
2022 return (game->get_maxmagic()>=game->get_mp_per_block());
2023
2024 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2025 {
2026
1/3
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3220277 switch(it)
2027 {
2028 case -2:
2029 {
2030 for(int32_t i=0; i<MAXLEVELS; i++)
2031 {
2032 if(game->lvlitems[i]&liTRIFORCE)
2033 {
2034 return true;
2035 }
2036 }
2037
2038 return false;
2039 }
2040
2041 case -1:
2042 return (game->lvlitems[dlevel]&liTRIFORCE);
2043
2044 default:
2045
2/4
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3220277 times.
3220277 if(it>=0&&it<MAXLEVELS)
2046 {
2047 3220277 return (game->lvlitems[it]&liTRIFORCE);
2048 }
2049
2050 break;
2051 }
2052
2053 return 0;
2054 }
2055
2056 case itype_map: //it: -2=any, -1=current level, other=that level
2057 {
2058
1/3
✓ Branch 0 taken 16010075 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
16010075 switch(it)
2059 {
2060 case -2:
2061 {
2062 for(int32_t i=0; i<MAXLEVELS; i++)
2063 {
2064 if(game->lvlitems[i]&liMAP)
2065 {
2066 return true;
2067 }
2068 }
2069
2070 return false;
2071 }
2072
2073 case -1:
2074 return (game->lvlitems[dlevel]&liMAP)!=0;
2075
2076 default:
2077
2/4
✓ Branch 0 taken 16010075 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16010075 times.
16010075 if(it>=0&&it<MAXLEVELS)
2078 {
2079 16010075 return (game->lvlitems[it]&liMAP)!=0;
2080 }
2081
2082 break;
2083 }
2084
2085 return 0;
2086 }
2087
2088 case itype_compass: //it: -2=any, -1=current level, other=that level
2089 {
2090
1/3
✓ Branch 0 taken 5337675 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5337675 switch(it)
2091 {
2092 case -2:
2093 {
2094 for(int32_t i=0; i<MAXLEVELS; i++)
2095 {
2096 if(game->lvlitems[i]&liCOMPASS)
2097 {
2098 return true;
2099 }
2100 }
2101
2102 return false;
2103 }
2104
2105 case -1:
2106 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2107
2108 default:
2109
2/4
✓ Branch 0 taken 5337675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5337675 times.
✗ Branch 3 not taken.
5337675 if(it>=0&&it<MAXLEVELS)
2110 {
2111 5337675 return (game->lvlitems[it]&liCOMPASS)!=0;
2112 }
2113
2114 break;
2115 }
2116 return 0;
2117 }
2118
2119 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2120 {
2121
1/3
✓ Branch 0 taken 41739 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
41739 switch(it)
2122 {
2123 case -2:
2124 {
2125 for(int32_t i=0; i<MAXLEVELS; i++)
2126 {
2127 if(game->lvlitems[i]&liBOSSKEY)
2128 {
2129 return true;
2130 }
2131 }
2132
2133 return false;
2134 }
2135
2136 case -1:
2137 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2138
2139 default:
2140
2/4
✓ Branch 0 taken 41739 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41739 times.
41739 if(it>=0&&it<MAXLEVELS)
2141 {
2142 41739 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2143 }
2144 break;
2145 }
2146 return 0;
2147 }
2148
2149 default:
2150 //it=(1<<(it-1));
2151 /*if (item_type>=itype_max)
2152 {
2153 enter_sys_pal();
2154 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2155 exit_sys_pal();
2156
2157 return false;
2158 }*/
2159 int32_t itemid = getItemID(itemsbuf, item_type, it);
2160
2161 if(itemid == -1)
2162 return false;
2163
2164 return game->get_item(itemid);
2165 }
2166 30661508 }
2167
2168
2169 99989559 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2170 {
2171
9/9
✓ Branch 0 taken 6051742 times.
✓ Branch 1 taken 51575623 times.
✓ Branch 2 taken 6051742 times.
✓ Branch 3 taken 6051742 times.
✓ Branch 4 taken 6051742 times.
✓ Branch 5 taken 6051742 times.
✓ Branch 6 taken 6051742 times.
✓ Branch 7 taken 6051742 times.
✓ Branch 8 taken 6051742 times.
99989559 switch(item_type)
2172 {
2173 case itype_clock:
2174 {
2175 6051742 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2176
2177
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6051742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6051742 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2178 return itemsbuf[maxid].fam_type;
2179
2180 6051742 return has_item(itype_clock,1) ? 1 : 0;
2181 }
2182
2183 case itype_key:
2184 6051742 return game->get_keys();
2185
2186 case itype_lkey:
2187 6051742 return game->lvlkeys[get_dlevel()];
2188
2189 case itype_magiccontainer:
2190 6051742 return game->get_maxmagic()/game->get_mp_per_block();
2191
2192 case itype_triforcepiece:
2193 {
2194 6051742 int32_t count=0;
2195
2196
2/2
✓ Branch 0 taken 3098491904 times.
✓ Branch 1 taken 6051742 times.
3104543646 for(int32_t i=0; i<MAXLEVELS; i++)
2197 {
2198 3098491904 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2199 3098491904 }
2200
2201 6051742 return count;
2202 }
2203
2204 case itype_map:
2205 {
2206 6051742 int32_t count=0;
2207
2208
2/2
✓ Branch 0 taken 3098491904 times.
✓ Branch 1 taken 6051742 times.
3104543646 for(int32_t i=0; i<MAXLEVELS; i++)
2209 {
2210 3098491904 count+=(game->lvlitems[i]&liMAP)?1:0;
2211 3098491904 }
2212
2213 6051742 return count;
2214 }
2215
2216 case itype_compass:
2217 {
2218 6051742 int32_t count=0;
2219
2220
2/2
✓ Branch 0 taken 3098491904 times.
✓ Branch 1 taken 6051742 times.
3104543646 for(int32_t i=0; i<MAXLEVELS; i++)
2221 {
2222 3098491904 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2223 3098491904 }
2224
2225 6051742 return count;
2226 }
2227
2228 case itype_bosskey:
2229 {
2230 6051742 int32_t count=0;
2231
2232
2/2
✓ Branch 0 taken 3098491904 times.
✓ Branch 1 taken 6051742 times.
3104543646 for(int32_t i=0; i<MAXLEVELS; i++)
2233 {
2234 3098491904 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2235 3098491904 }
2236
2237 6051742 return count;
2238 }
2239
2240 default:
2241 51575623 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2242
2243
2/2
✓ Branch 0 taken 9877306 times.
✓ Branch 1 taken 41698317 times.
51575623 if(maxid == -1)
2244 41698317 return 0;
2245
2246 9877306 return itemsbuf[maxid].fam_type;
2247 }
2248 99989559 }
2249
2250 92373933 int32_t current_item(int32_t item_type) //item currently being used
2251 {
2252 92373933 return current_item(item_type, true);
2253 }
2254
2255 45 std::map<int32_t, int32_t> itemcache;
2256
2257 // Not actually used by anything at the moment...
2258 void removeFromItemCache(int32_t itemclass)
2259 {
2260 itemcache.erase(itemclass);
2261 }
2262
2263 30020 void flushItemCache()
2264 {
2265 30020 itemcache.clear();
2266
2267 //also fix the active subscreen if items were deleted -DD
2268
1/2
✓ Branch 0 taken 30020 times.
✗ Branch 1 not taken.
30020 if(game != NULL)
2269 {
2270 30020 verifyBothWeapons();
2271 30020 load_Sitems();
2272 30020 }
2273 30020 }
2274
2275 // This is used often, so it should be as direct as possible.
2276 3369482014 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2277 {
2278
2/2
✓ Branch 0 taken 3293993904 times.
✓ Branch 1 taken 75488110 times.
3369482014 if(jinx_check)
2279 {
2280
4/4
✓ Branch 0 taken 47336776 times.
✓ Branch 1 taken 28151334 times.
✓ Branch 2 taken 39070013 times.
✓ Branch 3 taken 8266763 times.
75488110 if(!(HeroSwordClk() || HeroItemClk()))
2281 39070013 jinx_check = false; //not jinxed
2282 75488110 }
2283
4/4
✓ Branch 0 taken 3340101042 times.
✓ Branch 1 taken 29380972 times.
✓ Branch 2 taken 36085402 times.
✓ Branch 3 taken 3304015640 times.
3369482014 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2284 {
2285 3304015640 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2286
2287
2/2
✓ Branch 0 taken 3288688491 times.
✓ Branch 1 taken 15327149 times.
3304015640 if(res != itemcache.end())
2288 3288688491 return res->second;
2289 15327149 }
2290
2291 80793523 int32_t result = -1;
2292 80793523 int32_t highestlevel = -1;
2293
2294
2/2
✓ Branch 0 taken 20683141888 times.
✓ Branch 1 taken 80793523 times.
20763935411 for(int32_t i=0; i<MAXITEMS; i++)
2295 {
2296
5/6
✓ Branch 0 taken 1516747494 times.
✓ Branch 1 taken 19166394394 times.
✓ Branch 2 taken 21712494 times.
✓ Branch 3 taken 1495035000 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21712494 times.
20683141888 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2297 {
2298
4/4
✓ Branch 0 taken 5877480 times.
✓ Branch 1 taken 15835014 times.
✓ Branch 2 taken 1817053 times.
✓ Branch 3 taken 19895441 times.
21712494 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2299 {
2300 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2301
2/2
✓ Branch 0 taken 19895268 times.
✓ Branch 1 taken 173 times.
19895441 if(!checkmagiccost(i))
2302 {
2303
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 161 times.
173 if ( !get_qr(qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2304 12 }
2305 19895280 }
2306
6/6
✓ Branch 0 taken 18413091 times.
✓ Branch 1 taken 3299242 times.
✓ Branch 2 taken 311736 times.
✓ Branch 3 taken 2987506 times.
✓ Branch 4 taken 1796725 times.
✓ Branch 5 taken 1502517 times.
21712333 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2307 {
2308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1502517 times.
1502517 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2309 1502517 continue;
2310 }
2311
2312
2/2
✓ Branch 0 taken 278914 times.
✓ Branch 1 taken 19930902 times.
20209816 if(itemsbuf[i].fam_type >= highestlevel)
2313 {
2314 19930902 highestlevel = itemsbuf[i].fam_type;
2315 19930902 result=i;
2316 19930902 }
2317 20209816 }
2318 20681639210 }
2319
2320
2/2
✓ Branch 0 taken 36418097 times.
✓ Branch 1 taken 44375426 times.
80793523 if(!jinx_check) //Can't cache jinx_check results
2321 44375426 itemcache[itemtype] = result;
2322 80793523 return result;
2323 3369482014 }
2324
2325 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2326 3333508130 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2327 {
2328 3333508130 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2329
2/2
✓ Branch 0 taken 39514226 times.
✓ Branch 1 taken 3293993904 times.
3333508130 if(!jinx_check) //If not already a jinx-immune-only check...
2330 {
2331 //And the player IS jinxed...
2332
4/4
✓ Branch 0 taken 3266185547 times.
✓ Branch 1 taken 27808357 times.
✓ Branch 2 taken 8165527 times.
✓ Branch 3 taken 3258020020 times.
3293993904 if(HeroSwordClk() || HeroItemClk())
2333 {
2334 //Then do a jinx-immune-only check here
2335 35973884 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2336 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2337 //Should NOT need a compat rule, as this should always return -1 in old quests.
2338
2/2
✓ Branch 0 taken 1214282 times.
✓ Branch 1 taken 34759602 times.
35973884 if(ret2 > -1) return ret2;
2339 34759602 }
2340 3292779622 }
2341 3332293848 return ret;
2342 3333508130 }
2343 19237661 int32_t current_item_power(int32_t itemtype)
2344 {
2345 19237661 int32_t result = current_item_id(itemtype,true);
2346
2/2
✓ Branch 0 taken 13950085 times.
✓ Branch 1 taken 5287576 times.
19237661 return (result<0) ? 0 : itemsbuf[result].power;
2347 }
2348
2349 11 int32_t heart_container_id()
2350 {
2351
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 for(int32_t i=0; i<MAXITEMS; i++)
2352 {
2353
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 308 times.
319 if(itemsbuf[i].family == itype_heartcontainer)
2354 {
2355 11 return i;
2356 }
2357 308 }
2358 return -1;
2359 11 }
2360
2361 6051742 int32_t item_tile_mod()
2362 {
2363 6051742 int32_t tile=0;
2364
2365
2/2
✓ Branch 0 taken 1204731 times.
✓ Branch 1 taken 4847011 times.
6051742 if(game->get_bombs())
2366 {
2367 4847011 int32_t itemid = current_item_id(itype_bomb,false);
2368
3/4
✓ Branch 0 taken 4681842 times.
✓ Branch 1 taken 165169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4681842 times.
4847011 if(itemid > -1 && checkbunny(itemid))
2369 4681842 tile+=itemsbuf[itemid].ltm;
2370 4847011 }
2371
2372
2/2
✓ Branch 0 taken 4537666 times.
✓ Branch 1 taken 1514076 times.
6051742 if(game->get_sbombs())
2373 {
2374 1514076 int32_t itemid = current_item_id(itype_sbomb,false);
2375
3/4
✓ Branch 0 taken 1512648 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1512648 times.
1514076 if(itemid > -1 && checkbunny(itemid))
2376 1512648 tile+=itemsbuf[itemid].ltm;
2377 1514076 }
2378
2379
2/2
✓ Branch 0 taken 5942042 times.
✓ Branch 1 taken 109700 times.
6051742 if(current_item(itype_clock))
2380 {
2381 109700 int32_t itemid =
2382
1/2
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
109700 get_qr(qr_HARDCODED_LITEM_LTMS)
2383 ? iClock
2384 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2385
2/4
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109700 times.
109700 if(itemid > -1 && checkbunny(itemid))
2386 109700 tile+=itemsbuf[itemid].ltm;
2387 109700 }
2388
2389
2/2
✓ Branch 0 taken 4671001 times.
✓ Branch 1 taken 1380741 times.
6051742 if(current_item(itype_key))
2390 {
2391 1380741 int32_t itemid =
2392
1/2
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
1380741 get_qr(qr_HARDCODED_LITEM_LTMS)
2393 ? iKey
2394 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2395
2/4
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1380741 times.
1380741 if(itemid > -1 && checkbunny(itemid))
2396 1380741 tile+=itemsbuf[itemid].ltm;
2397 1380741 }
2398
2399
2/2
✓ Branch 0 taken 5784639 times.
✓ Branch 1 taken 267103 times.
6051742 if(current_item(itype_lkey))
2400 {
2401 267103 int32_t itemid =
2402
2/2
✓ Branch 0 taken 266193 times.
✓ Branch 1 taken 910 times.
267103 get_qr(qr_HARDCODED_LITEM_LTMS)
2403 ? iLevelKey
2404 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2405
2/4
✓ Branch 0 taken 267103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 267103 times.
267103 if(itemid > -1 && checkbunny(itemid))
2406 267103 tile+=itemsbuf[itemid].ltm;
2407 267103 }
2408
2409
2/2
✓ Branch 0 taken 1254925 times.
✓ Branch 1 taken 4796817 times.
6051742 if(current_item(itype_map))
2410 {
2411 4796817 int32_t itemid =
2412
2/2
✓ Branch 0 taken 4796031 times.
✓ Branch 1 taken 786 times.
4796817 get_qr(qr_HARDCODED_LITEM_LTMS)
2413 ? iMap
2414 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2415
2/4
✓ Branch 0 taken 4796817 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4796817 times.
4796817 if(itemid > -1 && checkbunny(itemid))
2416 4796817 tile+=itemsbuf[itemid].ltm;
2417 4796817 }
2418
2419
2/2
✓ Branch 0 taken 1233043 times.
✓ Branch 1 taken 4818699 times.
6051742 if(current_item(itype_compass))
2420 {
2421 4818699 int32_t itemid =
2422
2/2
✓ Branch 0 taken 4737640 times.
✓ Branch 1 taken 81059 times.
4818699 get_qr(qr_HARDCODED_LITEM_LTMS)
2423 ? iCompass
2424 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2425
2/4
✓ Branch 0 taken 4818699 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4818699 times.
4818699 if(itemid > -1 && checkbunny(itemid))
2426 4818699 tile+=itemsbuf[itemid].ltm;
2427 4818699 }
2428
2429
2/2
✓ Branch 0 taken 3421197 times.
✓ Branch 1 taken 2630545 times.
6051742 if(current_item(itype_bosskey))
2430 {
2431 2630545 int32_t itemid =
2432
1/2
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
2630545 get_qr(qr_HARDCODED_LITEM_LTMS)
2433 ? iBossKey
2434 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2435
2/4
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2630545 times.
2630545 if(itemid > -1 && checkbunny(itemid))
2436 2630545 tile+=itemsbuf[itemid].ltm;
2437 2630545 }
2438
2439
2/2
✓ Branch 0 taken 2917766 times.
✓ Branch 1 taken 3133976 times.
6051742 if(current_item(itype_magiccontainer))
2440 {
2441 3133976 int32_t itemid =
2442
2/2
✓ Branch 0 taken 3040989 times.
✓ Branch 1 taken 92987 times.
3133976 get_qr(qr_HARDCODED_LITEM_LTMS)
2443 ? iMagicC
2444 92987 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2445
3/4
✓ Branch 0 taken 3133976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 3132106 times.
3133976 if(itemid > -1 && checkbunny(itemid))
2446 3132106 tile+=itemsbuf[itemid].ltm;
2447 3133976 }
2448
2449
2/2
✓ Branch 0 taken 1591108 times.
✓ Branch 1 taken 4460634 times.
6051742 if(current_item(itype_triforcepiece))
2450 {
2451 4460634 int32_t itemid =
2452
1/2
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
4460634 get_qr(qr_HARDCODED_LITEM_LTMS)
2453 ? iTriforce
2454 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2455
2/4
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4460634 times.
4460634 if(itemid > -1 && checkbunny(itemid))
2456 4460634 tile+=itemsbuf[itemid].ltm;
2457 4460634 }
2458
2459
2/2
✓ Branch 0 taken 6051742 times.
✓ Branch 1 taken 3098491904 times.
3104543646 for(int32_t i=0; i<itype_max; i++)
2460 {
2461
2/2
✓ Branch 0 taken 3042451456 times.
✓ Branch 1 taken 56040448 times.
3098491904 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2462 {
2463
2/2
✓ Branch 0 taken 1094540 times.
✓ Branch 1 taken 54945908 times.
56040448 switch(i)
2464 {
2465 case itype_bomb:
2466 case itype_sbomb:
2467 case itype_clock:
2468 case itype_key:
2469 case itype_lkey:
2470 case itype_map:
2471 case itype_compass:
2472 case itype_bosskey:
2473 case itype_magiccontainer:
2474 case itype_triforcepiece:
2475 1094540 continue; //already handled
2476 }
2477 54945908 }
2478 3097397364 int32_t itemid = current_item_id(i,false);
2479
2/2
✓ Branch 0 taken 3091345622 times.
✓ Branch 1 taken 6051742 times.
3097397364 if(i == itype_shield)
2480 6051742 itemid = getCurrentShield(false);
2481
2482
4/4
✓ Branch 0 taken 80852064 times.
✓ Branch 1 taken 3016545300 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 80751083 times.
3097397364 if(itemid < 0 || !checkbunny(itemid))
2483 3016646281 continue;
2484
2485 80751083 itemdata const& itm = itemsbuf[itemid];
2486
2487
2/2
✓ Branch 0 taken 75336675 times.
✓ Branch 1 taken 5414408 times.
80751083 switch(itm.family)
2488 {
2489 case itype_shield:
2490
1/2
✓ Branch 0 taken 5414408 times.
✗ Branch 1 not taken.
5414408 if(itm.flags & ITEM_FLAG9) //active shield
2491 {
2492 if(!usingActiveShield(itemid))
2493 {
2494 tile+=itm.misc6; //'Inactive PTM'
2495 continue;
2496 }
2497 }
2498 5414408 break;
2499 }
2500
2501 80751083 tile+=itm.ltm;
2502 80751083 }
2503
2504 6051742 return tile;
2505 }
2506
2507 6051742 int32_t bunny_tile_mod()
2508 {
2509
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 6049872 times.
6051742 if(Hero.BunnyClock())
2510 {
2511 1870 return game->get_bunny_ltm();
2512 }
2513 6049872 return 0;
2514 6051742 }
2515
2516 // Hints are drawn on a separate layer to combo reveals.
2517 16332 void draw_lens_under(BITMAP *dest, bool layer)
2518 {
2519 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2520 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2521 //Lens flag 3: Don't show armos/chest/dive items
2522 //Lens flag 4: Show Raft Paths
2523 //Lens flag 5: Show Invisible Enemies
2524
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2525
2526 16332 int32_t strike_hint_table[11]=
2527 {
2528 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2529 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2530 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2531 };
2532
2533 // int32_t page = tmpscr->cpage;
2534 {
2535 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2536 // int32_t temptimer=0;
2537 16332 int32_t tempitem, tempweapon=0;
2538 16332 strike_hint=strike_hint_table[strike_hint_counter];
2539
2540
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2541 {
2542 492 strike_hint_timer=0;
2543 492 strike_hint_counter=((strike_hint_counter+1)%11);
2544 492 }
2545
2546 16332 ++strike_hint_timer;
2547
2548
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2549 {
2550 2874432 int32_t x = (i & 15) << 4;
2551 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2552 2874432 int32_t tempitemx=-16, tempitemy=-16;
2553 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2554
2555
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2556 {
2557 5748864 int32_t checkflag=0;
2558
2559
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2560 {
2561 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2562 2874432 }
2563 else
2564 {
2565 2874432 checkflag=tmpscr->sflag[i];
2566 }
2567
2568
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2569 {
2570
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2571 {
2572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2573 906 }
2574 else
2575 {
2576 192 checkflag = strike_hint;
2577 }
2578 1098 }
2579
2580
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2581 {
2582 case 0:
2583 case mfZELDA:
2584 case mfPUSHED:
2585 case mfENEMY0:
2586 case mfENEMY1:
2587 case mfENEMY2:
2588 case mfENEMY3:
2589 case mfENEMY4:
2590 case mfENEMY5:
2591 case mfENEMY6:
2592 case mfENEMY7:
2593 case mfENEMY8:
2594 case mfENEMY9:
2595 case mfSINGLE:
2596 case mfSINGLE16:
2597 case mfNOENEMY:
2598 case mfTRAP_H:
2599 case mfTRAP_V:
2600 case mfTRAP_4:
2601 case mfTRAP_LR:
2602 case mfTRAP_UD:
2603 case mfNOGROUNDENEMY:
2604 case mfNOBLOCKS:
2605 case mfSCRIPT1:
2606 case mfSCRIPT2:
2607 case mfSCRIPT3:
2608 case mfSCRIPT4:
2609 case mfSCRIPT5:
2610 case mfSCRIPT6:
2611 case mfSCRIPT7:
2612 case mfSCRIPT8:
2613 case mfSCRIPT9:
2614 case mfSCRIPT10:
2615 case mfSCRIPT11:
2616 case mfSCRIPT12:
2617 case mfSCRIPT13:
2618 case mfSCRIPT14:
2619 case mfSCRIPT15:
2620 case mfSCRIPT16:
2621 case mfSCRIPT17:
2622 case mfSCRIPT18:
2623 case mfSCRIPT19:
2624 case mfSCRIPT20:
2625 case mfPITHOLE:
2626 case mfPITFALLFLOOR:
2627 case mfLAVA:
2628 case mfICE:
2629 case mfICEDAMAGE:
2630 case mfDAMAGE1:
2631 case mfDAMAGE2:
2632 case mfDAMAGE4:
2633 case mfDAMAGE8:
2634 case mfDAMAGE16:
2635 case mfDAMAGE32:
2636 case mfFREEZEALL:
2637 case mfFREZEALLANSFFCS:
2638 case mfFREEZEFFCSOLY:
2639 case mfSCRITPTW1TRIG:
2640 case mfSCRITPTW2TRIG:
2641 case mfSCRITPTW3TRIG:
2642 case mfSCRITPTW4TRIG:
2643 case mfSCRITPTW5TRIG:
2644 case mfSCRITPTW6TRIG:
2645 case mfSCRITPTW7TRIG:
2646 case mfSCRITPTW8TRIG:
2647 case mfSCRITPTW9TRIG:
2648 case mfSCRITPTW10TRIG:
2649 case mfTROWEL:
2650 case mfTROWELNEXT:
2651 case mfTROWELSPECIALITEM:
2652 case mfSLASHPOT:
2653 case mfLIFTPOT:
2654 case mfLIFTORSLASH:
2655 case mfLIFTROCK:
2656 case mfLIFTROCKHEAVY:
2657 case mfDROPITEM:
2658 case mfSPECIALITEM:
2659 case mfDROPKEY:
2660 case mfDROPLKEY:
2661 case mfDROPCOMPASS:
2662 case mfDROPMAP:
2663 case mfDROPBOSSKEY:
2664 case mfSPAWNNPC:
2665 case mfSWITCHHOOK:
2666 case mfSIDEVIEWLADDER:
2667 case mfSIDEVIEWPLATFORM:
2668 case mfNOENEMYSPAWN:
2669 case mfENEMYALL:
2670 case mfNOMIRROR:
2671 case mfUNSAFEGROUND:
2672 case mf168:
2673 case mf169:
2674 case mf170:
2675 case mf171:
2676 case mf172:
2677 case mf173:
2678 case mf174:
2679 case mf175:
2680 case mf176:
2681 case mf177:
2682 case mf178:
2683 case mf179:
2684 case mf180:
2685 case mf181:
2686 case mf182:
2687 case mf183:
2688 case mf184:
2689 case mf185:
2690 case mf186:
2691 case mf187:
2692 case mf188:
2693 case mf189:
2694 case mf190:
2695 case mf191:
2696 case mf192:
2697 case mf193:
2698 case mf194:
2699 case mf195:
2700 case mf196:
2701 case mf197:
2702 case mf198:
2703 case mf199:
2704 case mf200:
2705 case mf201:
2706 case mf202:
2707 case mf203:
2708 case mf204:
2709 case mf205:
2710 case mf206:
2711 case mf207:
2712 case mf208:
2713 case mf209:
2714 case mf210:
2715 case mf211:
2716 case mf212:
2717 case mf213:
2718 case mf214:
2719 case mf215:
2720 case mf216:
2721 case mf217:
2722 case mf218:
2723 case mf219:
2724 case mf220:
2725 case mf221:
2726 case mf222:
2727 case mf223:
2728 case mf224:
2729 case mf225:
2730 case mf226:
2731 case mf227:
2732 case mf228:
2733 case mf229:
2734 case mf230:
2735 case mf231:
2736 case mf232:
2737 case mf233:
2738 case mf234:
2739 case mf235:
2740 case mf236:
2741 case mf237:
2742 case mf238:
2743 case mf239:
2744 case mf240:
2745 case mf241:
2746 case mf242:
2747 case mf243:
2748 case mf244:
2749 case mf245:
2750 case mf246:
2751 case mf247:
2752 case mf248:
2753 case mf249:
2754 case mf250:
2755 case mf251:
2756 case mf252:
2757 case mf253:
2758 case mf254:
2759 case mfEXTENDED:
2760 5706470 break;
2761
2762 case mfPUSHUD:
2763 case mfPUSHLR:
2764 case mfPUSH4:
2765 case mfPUSHU:
2766 case mfPUSHD:
2767 case mfPUSHL:
2768 case mfPUSHR:
2769 case mfPUSHUDNS:
2770 case mfPUSHLRNS:
2771 case mfPUSH4NS:
2772 case mfPUSHUNS:
2773 case mfPUSHDNS:
2774 case mfPUSHLNS:
2775 case mfPUSHRNS:
2776 case mfPUSHUDINS:
2777 case mfPUSHLRINS:
2778 case mfPUSH4INS:
2779 case mfPUSHUINS:
2780 case mfPUSHDINS:
2781 case mfPUSHLINS:
2782 case mfPUSHRINS:
2783
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2784
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2785 {
2786 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2787 }
2788
2789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2790
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2791 {
2792
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2793 {
2794
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2795 {
2796 case cPUSH_HEAVY:
2797 case cPUSH_HW:
2798 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2799 72 tempitemx=x, tempitemy=y;
2800
2801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2802 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2803
2804 72 break;
2805
2806 case cPUSH_HEAVY2:
2807 case cPUSH_HW2:
2808 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2809 63 tempitemx=x, tempitemy=y;
2810
2811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2812 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2813
2814 63 break;
2815 }
2816 1032 }
2817 2438 }
2818
2819 3148 break;
2820
2821 case mfWHISTLE:
2822
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2823 {
2824 tempitem=getItemID(itemsbuf,itype_whistle,1);
2825
2826 if(tempitem<0) break;
2827
2828 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2830 {
2831 tempitemx=x;
2832 tempitemy=y;
2833 }
2834
2835 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2836 }
2837
2838 2418 break;
2839
2840 //Why is this here?
2841 case mfFAIRY:
2842 case mfMAGICFAIRY:
2843 case mfALLFAIRY:
2844 if(hints)
2845 {
2846 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2847
2848 if(tempitem < 0) break;
2849
2850 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2851 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2852 {
2853 tempitemx=x;
2854 tempitemy=y;
2855 }
2856
2857 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2858 }
2859
2860 break;
2861
2862 case mfANYFIRE:
2863
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2864 {
2865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2866 252 }
2867 else
2868 {
2869 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2870
2871
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2872
2873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2874
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2875 {
2876 189 tempitemx=x;
2877 189 tempitemy=y;
2878 189 }
2879
2880 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2881 }
2882
2883 504 break;
2884
2885 case mfSTRONGFIRE:
2886 if(!hints)
2887 {
2888 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2889 }
2890 else
2891 {
2892 tempitem=getItemID(itemsbuf,itype_candle,2);
2893
2894 if(tempitem<0) break;
2895
2896 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2897 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2898 {
2899 tempitemx=x;
2900 tempitemy=y;
2901 }
2902
2903 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2904 }
2905
2906 break;
2907
2908 case mfMAGICFIRE:
2909 if(!hints)
2910 {
2911 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2912 }
2913 else
2914 {
2915 tempitem=getItemID(itemsbuf,itype_wand,1);
2916
2917 if(tempitem<0) break;
2918
2919 tempweapon=wFire;
2920
2921 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2922 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2923 {
2924 tempitemx=x;
2925 tempitemy=y;
2926 }
2927 else
2928 {
2929 tempweaponx=x;
2930 tempweapony=y;
2931 }
2932
2933 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2934 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2935 }
2936
2937 break;
2938
2939 case mfDIVINEFIRE:
2940 if(!hints)
2941 {
2942 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2943 }
2944 else
2945 {
2946 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2947
2948 if(tempitem<0) break;
2949
2950 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2951 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2952 {
2953 tempitemx=x;
2954 tempitemy=y;
2955 }
2956
2957 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2958 }
2959
2960 break;
2961
2962 case mfARROW:
2963
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2964 {
2965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2966 732 }
2967 else
2968 {
2969 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2970
2971
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2972
2973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2974
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2975 {
2976 61 tempitemx=x;
2977 61 tempitemy=y;
2978 61 }
2979
2980 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2981 }
2982
2983 814 break;
2984
2985 case mfSARROW:
2986 if(!hints)
2987 {
2988 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2989 }
2990 else
2991 {
2992 tempitem=getItemID(itemsbuf,itype_arrow,2);
2993
2994 if(tempitem<0) break;
2995
2996 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2997 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2998 {
2999 tempitemx=x;
3000 tempitemy=y;
3001 }
3002
3003 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3004 }
3005
3006 break;
3007
3008 case mfGARROW:
3009 if(!hints)
3010 {
3011 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3012 }
3013 else
3014 {
3015 tempitem=getItemID(itemsbuf,itype_arrow,3);
3016
3017 if(tempitem<0) break;
3018
3019 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3020 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3021 {
3022 tempitemx=x;
3023 tempitemy=y;
3024 }
3025
3026 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3027 }
3028
3029 break;
3030
3031 case mfBOMB:
3032
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3033 {
3034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3035 16 }
3036 else
3037 {
3038 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3039 17 tempweapon = wLitBomb;
3040
3041 //if (tempitem<0) break;
3042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3043
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3044 {
3045 12 tempweaponx=x;
3046 12 tempweapony=y;
3047 12 }
3048
3049 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3050 }
3051
3052 33 break;
3053
3054 case mfSBOMB:
3055
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3056 {
3057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3058 48 }
3059 else
3060 {
3061 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3062 //if (tempitem<0) break;
3063 48 tempweapon = wLitSBomb;
3064
3065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3066
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3067 {
3068 36 tempweaponx=x;
3069 36 tempweapony=y;
3070 36 }
3071
3072 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3073 }
3074
3075 96 break;
3076
3077 case mfARMOS_SECRET:
3078
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3079 {
3080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3081 12 }
3082 24 break;
3083
3084 case mfBRANG:
3085
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3086 {
3087 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3088 }
3089 else
3090 {
3091 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3092
3093
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3094
3095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3096
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3097 {
3098 4 tempitemx=x;
3099 4 tempitemy=y;
3100 4 }
3101
3102 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3103 }
3104
3105 5 break;
3106
3107 case mfMBRANG:
3108 if(!hints)
3109 {
3110 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3111 }
3112 else
3113 {
3114 tempitem=getItemID(itemsbuf,itype_brang,2);
3115
3116 if(tempitem<0) break;
3117
3118 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3119 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3120 {
3121 tempitemx=x;
3122 tempitemy=y;
3123 }
3124
3125 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3126 }
3127
3128 break;
3129
3130 case mfFBRANG:
3131 if(!hints)
3132 {
3133 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3134 }
3135 else
3136 {
3137 tempitem=getItemID(itemsbuf,itype_brang,3);
3138
3139 if(tempitem<0) break;
3140
3141 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3142 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3143 {
3144 tempitemx=x;
3145 tempitemy=y;
3146 }
3147
3148 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3149 }
3150
3151 break;
3152
3153 case mfWANDMAGIC:
3154 if(!hints)
3155 {
3156 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3157 }
3158 else
3159 {
3160 tempitem=getItemID(itemsbuf,itype_wand,1);
3161
3162 if(tempitem<0) break;
3163
3164 tempweapon=itemsbuf[tempitem].wpn3;
3165
3166 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3167 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3168 {
3169 tempitemx=x;
3170 tempitemy=y;
3171 }
3172 else
3173 {
3174 tempweaponx=x;
3175 tempweapony=y;
3176 --lens_hint_weapon[wMagic][4];
3177
3178 if(lens_hint_weapon[wMagic][4]<-8)
3179 {
3180 lens_hint_weapon[wMagic][4]=8;
3181 }
3182 }
3183
3184 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3185 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3186 }
3187
3188 break;
3189
3190 case mfREFMAGIC:
3191
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3192 {
3193 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3194 }
3195 else
3196 {
3197 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3198
3199
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3200
3201 16 tempweapon=ewMagic;
3202
3203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3204
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3205 {
3206 13 tempitemx=x;
3207 13 tempitemy=y;
3208 13 }
3209 else
3210 {
3211 3 tempweaponx=x;
3212 3 tempweapony=y;
3213
3214
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3215 {
3216 1 --lens_hint_weapon[ewMagic][4];
3217 1 }
3218 else
3219 {
3220 2 ++lens_hint_weapon[ewMagic][4];
3221 }
3222
3223
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3224 {
3225 lens_hint_weapon[ewMagic][2]=up;
3226 }
3227
3228
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3229 {
3230 2 lens_hint_weapon[ewMagic][2]=down;
3231 2 }
3232 }
3233
3234 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3235 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3236 }
3237
3238 16 break;
3239
3240 case mfREFFIREBALL:
3241
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3242 {
3243 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3244 }
3245 else
3246 {
3247 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3248
3249
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3250
3251 16 tempweapon=ewFireball;
3252
3253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3254
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3255 {
3256 12 tempitemx=x;
3257 12 tempitemy=y;
3258 12 tempweaponx=x;
3259 12 tempweapony=y;
3260 12 ++lens_hint_weapon[ewFireball][3];
3261
3262
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3263 {
3264 1 lens_hint_weapon[ewFireball][3]=-8;
3265 1 lens_hint_weapon[ewFireball][4]=8;
3266 1 }
3267
3268
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3269 {
3270 8 ++lens_hint_weapon[ewFireball][4];
3271 8 }
3272 else
3273 {
3274 4 --lens_hint_weapon[ewFireball][4];
3275 }
3276 12 }
3277
3278 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3279 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3280 }
3281
3282 16 break;
3283
3284 case mfSWORD:
3285
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3286 {
3287 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3288 }
3289 else
3290 {
3291 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3292
3293
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3294
3295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3296
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3297 {
3298 5 tempitemx=x;
3299 5 tempitemy=y;
3300 5 }
3301
3302 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3303 }
3304
3305 7 break;
3306
3307 case mfWSWORD:
3308 if(!hints)
3309 {
3310 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3311 }
3312 else
3313 {
3314 tempitem=getItemID(itemsbuf,itype_sword,2);
3315
3316 if(tempitem<0) break;
3317
3318 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3319 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3320 {
3321 tempitemx=x;
3322 tempitemy=y;
3323 }
3324
3325 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3326 }
3327
3328 break;
3329
3330 case mfMSWORD:
3331 if(!hints)
3332 {
3333 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3334 }
3335 else
3336 {
3337 tempitem=getItemID(itemsbuf,itype_sword,3);
3338
3339 if(tempitem<0) break;
3340
3341 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3342 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3343 {
3344 tempitemx=x;
3345 tempitemy=y;
3346 }
3347
3348 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3349 }
3350
3351 break;
3352
3353 case mfXSWORD:
3354 if(!hints)
3355 {
3356 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3357 }
3358 else
3359 {
3360 tempitem=getItemID(itemsbuf,itype_sword,4);
3361
3362 if(tempitem<0) break;
3363
3364 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3365 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3366 {
3367 tempitemx=x;
3368 tempitemy=y;
3369 }
3370
3371 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3372 }
3373
3374 break;
3375
3376 case mfSWORDBEAM:
3377
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3378 {
3379 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3380 }
3381 else
3382 {
3383 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3384
3385
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3386
3387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3388
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3389 {
3390 11 tempitemx=x;
3391 11 tempitemy=y;
3392 11 }
3393
3394 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3395 }
3396
3397 16 break;
3398
3399 case mfWSWORDBEAM:
3400 if(!hints)
3401 {
3402 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3403 }
3404 else
3405 {
3406 tempitem=getItemID(itemsbuf,itype_sword,2);
3407
3408 if(tempitem<0) break;
3409
3410 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3411 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3412 {
3413 tempitemx=x;
3414 tempitemy=y;
3415 }
3416
3417 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3418 }
3419
3420 break;
3421
3422 case mfMSWORDBEAM:
3423 if(!hints)
3424 {
3425 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3426 }
3427 else
3428 {
3429 tempitem=getItemID(itemsbuf,itype_sword,3);
3430
3431 if(tempitem<0) break;
3432
3433 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3434 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3435 {
3436 tempitemx=x;
3437 tempitemy=y;
3438 }
3439
3440 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3441 }
3442
3443 break;
3444
3445 case mfXSWORDBEAM:
3446 if(!hints)
3447 {
3448 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3449 }
3450 else
3451 {
3452 tempitem=getItemID(itemsbuf,itype_sword,4);
3453
3454 if(tempitem<0) break;
3455
3456 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3457 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3458 {
3459 tempitemx=x;
3460 tempitemy=y;
3461 }
3462
3463 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3464 }
3465
3466 break;
3467
3468 case mfHOOKSHOT:
3469
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3470 {
3471 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3472 }
3473 else
3474 {
3475 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3476
3477
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3478
3479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3480
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3481 {
3482 12 tempitemx=x;
3483 12 tempitemy=y;
3484 12 }
3485
3486 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3487 }
3488
3489 17 break;
3490
3491 case mfWAND:
3492
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3493 {
3494 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3495 }
3496 else
3497 {
3498 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3499
3500
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3501
3502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3503
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3504 {
3505 28 tempitemx=x;
3506 28 tempitemy=y;
3507 28 }
3508
3509 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3510 }
3511
3512 35 break;
3513
3514 case mfHAMMER:
3515
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3516 {
3517 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3518 }
3519 else
3520 {
3521 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3522
3523
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3524
3525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3526
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3527 {
3528 13 tempitemx=x;
3529 13 tempitemy=y;
3530 13 }
3531
3532 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3533 }
3534
3535 17 break;
3536
3537 case mfARMOS_ITEM:
3538 case mfDIVE_ITEM:
3539
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3540 {
3541 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3542 2064 }
3543 2064 break;
3544
3545 case 16:
3546 case 17:
3547 case 18:
3548 case 19:
3549 case 20:
3550 case 21:
3551 case 22:
3552 case 23:
3553 case 24:
3554 case 25:
3555 case 26:
3556 case 27:
3557 case 28:
3558 case 29:
3559 case 30:
3560 case 31:
3561
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3563 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3564
3565 3618 break;
3566 case mfSECRETSNEXT:
3567 if(!hints)
3568 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3569 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3570
3571 break;
3572
3573 case mfSTRIKE:
3574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3575 {
3576 906 goto special;
3577 }
3578 else
3579 {
3580 break;
3581 }
3582
3583 28640 default: goto special;
3584
3585 special:
3586
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3587 {
3588
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3589 {
3590 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3591 4913 }
3592 6549 }
3593
3594 29546 break;
3595 }
3596 5748864 }
3597 2874432 }
3598
3599
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3600 {
3601
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3602 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3603
3604
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3605 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3606
3607
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3608 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3609
3610
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3611 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3612
3613
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3614 {
3615 43 showbombeddoor(dest, 0);
3616 43 }
3617
3618
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3619 {
3620 39 showbombeddoor(dest, 1);
3621 39 }
3622
3623
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3624 {
3625 showbombeddoor(dest, 2);
3626 }
3627
3628
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3629 {
3630 37 showbombeddoor(dest, 3);
3631 37 }
3632 8166 }
3633
3634
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3635 {
3636
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3637 {
3638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3639 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3640 1123 }
3641 else
3642 {
3643
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3644 {
3645 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3646 48 int32_t tempitemx=-16;
3647 48 int32_t tempitemy=-16;
3648
3649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3650
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3651 {
3652 24 tempitemx=tmpscr->stairx;
3653 24 tempitemy=tmpscr->stairy+playing_field_offset;
3654 24 }
3655
3656 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3657 48 }
3658 }
3659 2034 }
3660 }
3661 16332 }
3662
3663 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3664
3665 7997 void draw_lens_over()
3666 {
3667 // Oh, what the heck.
3668 static BITMAP *lens_scr = NULL;
3669 static int32_t last_width = -1;
3670 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3671
3672 // Only redraw the circle if the size has changed
3673
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3674 {
3675
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3676 {
3677 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3678 5 }
3679
3680 5 clear_to_color(lens_scr, BLACK);
3681 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3682 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3683 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3684 5 last_width=width;
3685 5 }
3686
3687 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3688 7997 }
3689
3690 //----------------------------------------------------------------
3691
3692 31111 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3693 {
3694 //recreating a big bitmap every frame is highly sluggish.
3695
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 31108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
31111 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3696 31111 clear_to_color(wavebuf, BLACK);
3697 31111 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3698
3699 int32_t ofs;
3700 // int32_t amplitude=8;
3701 // int32_t wavelength=4;
3702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31111 times.
31111 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3703
3/6
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3704 31111 int32_t amp2=168;
3705
2/4
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3706 31111 int32_t i=frame%amp2;
3707
3708
2/2
✓ Branch 0 taken 5226648 times.
✓ Branch 1 taken 31111 times.
5257759 for(int32_t j=0; j<168; j++)
3709 {
3710
3/4
✓ Branch 0 taken 2613324 times.
✓ Branch 1 taken 2613324 times.
✓ Branch 2 taken 2613324 times.
✗ Branch 3 not taken.
5226648 if(j&1 && interpol)
3711 {
3712 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3713 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3714 }
3715 else
3716 {
3717 5226648 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3718 }
3719
3720
1/2
✓ Branch 0 taken 5226648 times.
✗ Branch 1 not taken.
5226648 if(ofs)
3721 {
3722
2/2
✓ Branch 0 taken 1338021888 times.
✓ Branch 1 taken 5226648 times.
1343248536 for(int32_t k=0; k<256; k++)
3723 {
3724 1338021888 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3725 1338021888 }
3726 5226648 }
3727 5226648 }
3728 31111 }
3729
3730 4848 void draw_fuzzy(int32_t fuzz)
3731 // draws from right half of scrollbuf to framebuf
3732 {
3733 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3734 byte *start, *si, *di;
3735
3736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4848 times.
4848 if(fuzz<1)
3737 fuzz = 1;
3738
3739 4848 xstep = 128%fuzz;
3740
3741
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 3838 times.
4848 if(xstep > 0)
3742 3838 xstep = fuzz-xstep;
3743
3744 4848 ystep = 112%fuzz;
3745
3746
2/2
✓ Branch 0 taken 1414 times.
✓ Branch 1 taken 3434 times.
4848 if(ystep > 0)
3747 3434 ystep = fuzz-ystep;
3748
3749 4848 firsty = 1;
3750
3751
2/2
✓ Branch 0 taken 4848 times.
✓ Branch 1 taken 174932 times.
179780 for(y=0; y<224;)
3752 {
3753 174932 start = &(scrollbuf->line[y][256]);
3754
3755
4/4
✓ Branch 0 taken 172508 times.
✓ Branch 1 taken 1088376 times.
✓ Branch 2 taken 1085952 times.
✓ Branch 3 taken 174932 times.
1260884 for(dy=0; dy<ystep && dy+y<224; dy++)
3756 {
3757 1085952 si = start;
3758 1085952 di = &(framebuf->line[y+dy][0]);
3759 1085952 i = xstep;
3760 1085952 firstx = 1;
3761
3762
2/2
✓ Branch 0 taken 278003712 times.
✓ Branch 1 taken 1085952 times.
279089664 for(dx=0; dx<256; dx++)
3763 {
3764 278003712 *(di++) = *si;
3765
3766
2/2
✓ Branch 0 taken 234248896 times.
✓ Branch 1 taken 43754816 times.
278003712 if(++i >= fuzz)
3767 {
3768
2/2
✓ Branch 0 taken 42668864 times.
✓ Branch 1 taken 1085952 times.
43754816 if(!firstx)
3769 42668864 si += fuzz;
3770 else
3771 {
3772 1085952 si += fuzz-xstep;
3773 1085952 firstx = 0;
3774 }
3775
3776 43754816 i = 0;
3777 43754816 }
3778 278003712 }
3779 1085952 }
3780
3781
2/2
✓ Branch 0 taken 170084 times.
✓ Branch 1 taken 4848 times.
174932 if(!firsty)
3782 170084 y += fuzz;
3783 else
3784 {
3785 4848 y += ystep;
3786 4848 ystep = fuzz;
3787 4848 firsty = 0;
3788 }
3789 }
3790 4848 }
3791
3792 9285010 void updatescr(bool allowwavy)
3793 {
3794
4/6
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 9284965 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
9285010 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3795
4/6
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 9284965 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 45 times.
9285010 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3796
3797
2/2
✓ Branch 0 taken 9258245 times.
✓ Branch 1 taken 26765 times.
9285010 if(toogam)
3798 {
3799 26765 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3800 26765 }
3801
3802
1/2
✓ Branch 0 taken 9285010 times.
✗ Branch 1 not taken.
9285010 if(Showpal)
3803 dump_pal(framebuf);
3804
3805
2/2
✓ Branch 0 taken 8983947 times.
✓ Branch 1 taken 301063 times.
9285010 if(!Playing)
3806 301063 black_opening_count=0;
3807
3808
2/2
✓ Branch 0 taken 9211816 times.
✓ Branch 1 taken 73194 times.
9285010 if(black_opening_count<0) //shape is opening up
3809 {
3810 73194 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3811
3812
2/4
✓ Branch 0 taken 73194 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73194 times.
73194 if(Advance||(!Paused))
3813 {
3814 73194 ++black_opening_count;
3815 73194 }
3816 73194 }
3817
2/2
✓ Branch 0 taken 9185680 times.
✓ Branch 1 taken 26136 times.
9211816 else if(black_opening_count>0) //shape is closing
3818 {
3819 26136 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3820
3821
2/4
✓ Branch 0 taken 26136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26136 times.
26136 if(Advance||(!Paused))
3822 {
3823 26136 --black_opening_count;
3824 26136 }
3825 26136 }
3826
3827
3/4
✓ Branch 0 taken 9187185 times.
✓ Branch 1 taken 97825 times.
✓ Branch 2 taken 9187185 times.
✗ Branch 3 not taken.
9285010 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3828 {
3829 black_opening_shape = bosCIRCLE;
3830 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3831 refreshTints();
3832 refreshpal=true;
3833 }
3834
3835
2/2
✓ Branch 0 taken 9030812 times.
✓ Branch 1 taken 254198 times.
9285010 if(refreshpal)
3836 {
3837 254198 refreshpal=false;
3838 254198 RAMpal[253] = _RGB(0,0,0);
3839 254198 RAMpal[254] = _RGB(63,63,63);
3840 254198 hw_palette = &RAMpal;
3841 254198 update_hw_pal = true;
3842
3843 254198 create_rgb_table(&rgb_table, RAMpal, NULL);
3844 254198 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3845 254198 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3846
3847
2/2
✓ Branch 0 taken 65074688 times.
✓ Branch 1 taken 254198 times.
65328886 for(int32_t q=0; q<PAL_SIZE; q++)
3848 {
3849 65074688 trans_table2.data[0][q] = q;
3850 65074688 trans_table2.data[q][q] = q;
3851 65074688 }
3852 254198 }
3853
3854 9285010 bool clearwavy = (wavy <= 0);
3855
3856
2/2
✓ Branch 0 taken 7655 times.
✓ Branch 1 taken 9277355 times.
9285010 if(wavy <= 0)
3857 {
3858 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3859 9277355 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3860 9277355 }
3861
3862 9285010 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3863
3864
6/6
✓ Branch 0 taken 31361 times.
✓ Branch 1 taken 9253649 times.
✓ Branch 2 taken 31239 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31111 times.
9285010 if(wavy && Playing && allowwavy)
3865 {
3866 31111 draw_wavy(framebuf, wavybuf, wavy,false);
3867 31111 }
3868
3869
2/2
✓ Branch 0 taken 9277355 times.
✓ Branch 1 taken 7655 times.
9285010 if(clearwavy)
3870 9277355 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3871
2/4
✓ Branch 0 taken 7655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7655 times.
7655 else if(Playing && !Paused)
3872 7655 wavy--; // Wavy was set by a script. Decrement it.
3873
3874
5/6
✓ Branch 0 taken 8983947 times.
✓ Branch 1 taken 301063 times.
✓ Branch 2 taken 259574 times.
✓ Branch 3 taken 8724373 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 259574 times.
9285010 if(Playing && msgpos && !screenscrolling)
3875 {
3876
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_bg_display_buf->clip))
3877 259574 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3878
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_portrait_display_buf->clip))
3879 259574 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3880
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_txt_display_buf->clip))
3881 259574 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3882 259574 }
3883
3884 /*
3885 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3886 {
3887 BITMAP* subBmp = 0;
3888 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3889 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3890 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3891 destroy_bitmap(subBmp);
3892 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3893 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3894 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3895 }
3896 */
3897
3898
2/2
✓ Branch 0 taken 9243953 times.
✓ Branch 1 taken 41057 times.
9285010 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3899
3900
2/2
✓ Branch 0 taken 9248578 times.
✓ Branch 1 taken 36432 times.
9285010 if(nosubscr)
3901 {
3902 36432 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3903 36432 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3904 36432 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3905 36432 }
3906
3907 //TODO: Optimize blit 'overcalls' -Gleeok
3908
2/2
✓ Branch 0 taken 36432 times.
✓ Branch 1 taken 9248578 times.
9285010 BITMAP *source = nosubscr ? panorama : wavybuf;
3909 9285010 blit(source,framebuf,0,0,0,0,256,224);
3910
3911 9285010 update_hw_screen();
3912 9285010 }
3913
3914 //----------------------------------------------------------------
3915
3916 static PALETTE syspal;
3917 int32_t onGUISnapshot()
3918 {
3919 char buf[200];
3920 int32_t num=0;
3921 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3922 do
3923 {
3924 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3925 }
3926 while(num<99999 && exists(buf));
3927
3928 BITMAP *b = create_bitmap_ex(8,resx,resy);
3929
3930 if(b)
3931 {
3932 blit(screen,b,0,0,0,0,resx,resy);
3933 save_bitmap(buf,b,RAMpal);
3934 destroy_bitmap(b);
3935 }
3936
3937 return D_O_K;
3938 }
3939
3940 int32_t onNonGUISnapshot()
3941 {
3942 PALETTE temppal;
3943 get_palette(temppal);
3944 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3945
3946 char buf[200];
3947 int32_t num=0;
3948
3949 do
3950 {
3951 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3952 }
3953 while(num<99999 && exists(buf));
3954
3955 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3956
3957 return D_O_K;
3958 }
3959
3960 int32_t onSnapshot()
3961 {
3962 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3963 {
3964 onGUISnapshot();
3965 }
3966 else
3967 {
3968 onNonGUISnapshot();
3969 }
3970
3971 return D_O_K;
3972 }
3973
3974 int32_t onSaveMapPic()
3975 {
3976 int32_t mapres2 = 0;
3977 char buf[200];
3978 int32_t num=0;
3979 mapscr tmpscr_b[2];
3980 mapscr tmpscr_c[6];
3981 BITMAP* _screen_draw_buffer = NULL;
3982 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3983 set_clip_state(_screen_draw_buffer,1);
3984
3985 for(int32_t i=0; i<6; ++i)
3986 {
3987 tmpscr_c[i] = tmpscr2[i];
3988 tmpscr2[i].zero_memory();
3989
3990 if(i>=2)
3991 {
3992 continue;
3993 }
3994
3995 tmpscr_b[i] = tmpscr[i];
3996 tmpscr[i].zero_memory();
3997 }
3998
3999 do
4000 {
4001 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4002 }
4003 while(num<99999 && exists(buf));
4004
4005 BITMAP* mappic = NULL;
4006
4007
4008 bool done=false, redraw=true;
4009
4010 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4011
4012 if(!mappic)
4013 {
4014 enter_sys_pal();
4015 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4016 exit_sys_pal();
4017 return D_O_K;;
4018 }
4019
4020 // draw the map
4021 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4022
4023 for(int32_t y=0; y<8; y++)
4024 {
4025 for(int32_t x=0; x<16; x++)
4026 {
4027 if(!displayOnMap(x, y))
4028 {
4029 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4030 }
4031 else
4032 {
4033 int32_t s = (y<<4) + x;
4034 loadscr2(1,s,-1);
4035
4036 for(int32_t i=0; i<6; i++)
4037 {
4038 if(tmpscr[1].layermap[i]<=0)
4039 continue;
4040
4041 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4042 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4043 {
4044 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4045
4046 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4047 }
4048 }
4049
4050 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4051
4052 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4053
4054 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4055 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4056
4057 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4058
4059 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4060 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4061 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4062 {
4063 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4064 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4065 }
4066 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4067
4068 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4069
4070 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4071 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4072 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4073 {
4074 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4075 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4076 }
4077 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4078 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4079
4080 }
4081
4082 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4083 }
4084 }
4085
4086 for(int32_t i=0; i<6; ++i)
4087 {
4088 tmpscr2[i]=tmpscr_c[i];
4089
4090 if(i>=2)
4091 {
4092 continue;
4093 }
4094
4095 tmpscr[i]=tmpscr_b[i];
4096 }
4097
4098 save_bitmap(buf,mappic,RAMpal);
4099 destroy_bitmap(mappic);
4100 destroy_bitmap(_screen_draw_buffer);
4101 return D_O_K;
4102 }
4103
4104 13 void f_Quit(int32_t type)
4105 {
4106
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(type==qQUIT && !Playing)
4107 return;
4108
4109 13 bool from_menu = is_sys_pal;
4110
4111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!from_menu)
4112 {
4113 13 music_pause();
4114 13 pause_all_sfx();
4115 13 sys_mouse();
4116 13 }
4117 13 enter_sys_pal();
4118 13 clear_keybuf();
4119
4120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (replay_version_check(0, 10))
4121 13 replay_poll();
4122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (replay_is_replaying())
4123 13 replay_peek_quit();
4124
4125
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (!replay_is_replaying())
4126 switch(type)
4127 {
4128 case qQUIT:
4129 onQuit();
4130 break;
4131
4132 case qRESET:
4133 onReset();
4134 break;
4135
4136 case qEXIT:
4137 onExit();
4138 break;
4139 }
4140
4141
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Quit)
4142 {
4143 13 kill_sfx();
4144 13 music_stop();
4145 13 exit_sys_pal();
4146 13 update_hw_screen();
4147 13 }
4148 else
4149 {
4150 exit_sys_pal();
4151 if(!from_menu)
4152 {
4153 music_resume();
4154 resume_all_sfx();
4155 }
4156 }
4157
4158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!from_menu)
4159 13 game_mouse();
4160 13 eat_buttons();
4161
4162 13 zc_readrawkey(KEY_ESC);
4163
4164 13 zc_readrawkey(KEY_ENTER);
4165 13 }
4166
4167 //----------------------------------------------------------------
4168
4169 int32_t onNoWalls()
4170 {
4171 cheats_enqueue(Cheat::Walls);
4172 return D_O_K;
4173 }
4174
4175 int32_t onIgnoreSideview()
4176 {
4177 cheats_enqueue(Cheat::IgnoreSideView);
4178 return D_O_K;
4179 }
4180
4181 9284885 int32_t input_idle(bool checkmouse)
4182 {
4183 static int32_t mx, my, mz, mb;
4184
4185
4/6
✓ Branch 0 taken 9284885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461199 times.
✓ Branch 3 taken 6823686 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2461199 times.
11746084 if(keypressed() || zc_key_pressed() ||
4186
4/8
✓ Branch 0 taken 2461199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461199 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2461199 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2461199 times.
✗ Branch 7 not taken.
2461199 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4187 {
4188 6823686 idle_count = 0;
4189
4190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6823686 times.
6823686 if(active_count < MAX_ACTIVE)
4191 {
4192 6823686 ++active_count;
4193 6823686 }
4194 6823686 }
4195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2461199 times.
2461199 else if(idle_count < MAX_IDLE)
4196 {
4197 2461199 ++idle_count;
4198 2461199 active_count = 0;
4199 2461199 }
4200
4201 9284885 mx = mouse_x;
4202 9284885 my = mouse_y;
4203 9284885 mz = mouse_z;
4204 9284885 mb = mouse_b;
4205
4206 9284885 return idle_count;
4207 }
4208
4209 int32_t onGoFast()
4210 {
4211 cheats_enqueue(Cheat::Fast);
4212 return D_O_K;
4213 }
4214
4215 int32_t onKillCheat()
4216 {
4217 cheats_enqueue(Cheat::Kill);
4218 return D_O_K;
4219 }
4220
4221 int32_t onSecretsCheat()
4222 {
4223 cheats_enqueue(Cheat::TrigSecrets);
4224 return D_O_K;
4225 }
4226 int32_t onSecretsCheatPerm()
4227 {
4228 cheats_enqueue(Cheat::TrigSecretsPerm);
4229 return D_O_K;
4230 }
4231
4232 int32_t onShowLayer0()
4233 {
4234 show_layer_0 = !show_layer_0;
4235 return D_O_K;
4236 }
4237 int32_t onShowLayer1()
4238 {
4239 show_layer_1 = !show_layer_1;
4240 return D_O_K;
4241 }
4242 int32_t onShowLayer2()
4243 {
4244 show_layer_2 = !show_layer_2;
4245 return D_O_K;
4246 }
4247 int32_t onShowLayer3()
4248 {
4249 show_layer_3 = !show_layer_3;
4250 return D_O_K;
4251 }
4252 int32_t onShowLayer4()
4253 {
4254 show_layer_4 = !show_layer_4;
4255 return D_O_K;
4256 }
4257 int32_t onShowLayer5()
4258 {
4259 show_layer_5 = !show_layer_5;
4260 return D_O_K;
4261 }
4262 int32_t onShowLayer6()
4263 {
4264 show_layer_6 = !show_layer_6;
4265 return D_O_K;
4266 }
4267 int32_t onShowLayerO()
4268 {
4269 show_layer_over=!show_layer_over;
4270 return D_O_K;
4271 }
4272 int32_t onShowLayerP()
4273 {
4274 show_layer_push=!show_layer_push;
4275 return D_O_K;
4276 }
4277 int32_t onShowLayerS()
4278 {
4279 show_sprites=!show_sprites;
4280 return D_O_K;
4281 }
4282 int32_t onShowLayerF()
4283 {
4284 show_ffcs=!show_ffcs;
4285 return D_O_K;
4286 }
4287 int32_t onShowLayerW()
4288 {
4289 show_walkflags=!show_walkflags;
4290 if(show_walkflags)
4291 show_effectflags = false;
4292 return D_O_K;
4293 }
4294 int32_t onShowLayerE()
4295 {
4296 show_effectflags=!show_effectflags;
4297 if(show_effectflags)
4298 show_walkflags = false;
4299 return D_O_K;
4300 }
4301 int32_t onShowFFScripts()
4302 {
4303 show_ff_scripts=!show_ff_scripts;
4304 return D_O_K;
4305 }
4306 int32_t onShowHitboxes()
4307 {
4308 show_hitboxes=!show_hitboxes;
4309 return D_O_K;
4310 }
4311 int32_t onShowInfoOpacity()
4312 {
4313 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4314 zc_set_config("zc","debug_info_opacity",info_opacity);
4315 return D_O_K;
4316 }
4317
4318 int32_t onLightSwitch()
4319 {
4320 cheats_enqueue(Cheat::Light);
4321 return D_O_K;
4322 }
4323
4324 int32_t onGoTo();
4325 int32_t onGoToComplete();
4326
4327 9284885 void syskeys()
4328 {
4329 9284885 update_system_keys();
4330
4331 int32_t oldtitle_version;
4332
4333
1/2
✓ Branch 0 taken 9284885 times.
✗ Branch 1 not taken.
9284885 if(close_button_quit)
4334 {
4335 close_button_quit=false;
4336 f_Quit(qEXIT);
4337 }
4338
4339 9284885 poll_joystick();
4340
4341
2/10
✓ Branch 0 taken 9284885 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9284885 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9284885 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4342 {
4343 oldtitle_version=title_version;
4344 System();
4345 }
4346
4347 9284885 mouse_down=gui_mouse_b();
4348
4349
1/2
✓ Branch 0 taken 9284885 times.
✗ Branch 1 not taken.
9284885 if(zc_read_system_key(KEY_F1))
4350 {
4351 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4352 {
4353 halt=!halt;
4354 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4355 }
4356 else
4357 {
4358 Throttlefps=!Throttlefps;
4359 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4360 }
4361 }
4362
4363 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4364 /*
4365 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4366 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4367 */
4368
4369
1/2
✓ Branch 0 taken 9284885 times.
✗ Branch 1 not taken.
9284885 if(zc_read_system_key(KEY_F2))
4370 {
4371 ShowFPS=!ShowFPS;
4372 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4373 }
4374
4375
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9284885 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9284885 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4376
4377
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9284885 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9284885 if(zc_read_system_key(KEY_F4) && Playing)
4378 {
4379 Paused=true;
4380 Advance=true;
4381 }
4382
4383
1/2
✓ Branch 0 taken 9284885 times.
✗ Branch 1 not taken.
9284885 if(zc_read_system_key(KEY_F6)) onTryQuit();
4384
4385 #ifndef ALLEGRO_MACOSX
4386
1/2
✓ Branch 0 taken 9284885 times.
✗ Branch 1 not taken.
9284885 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4387
4388
1/2
✓ Branch 0 taken 9284885 times.
✗ Branch 1 not taken.
9284885 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4389 #else
4390 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4391
4392 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4393 #endif
4394
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9284885 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9284885 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4395
4396
1/2
✓ Branch 0 taken 9284885 times.
✗ Branch 1 not taken.
9284885 if (zc_read_system_key(KEY_F12))
4397 {
4398 onSnapshot();
4399 }
4400
4401
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9284885 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9284885 if(debug_enabled && zc_read_system_key(KEY_TAB))
4402 set_debug(!get_debug());
4403
4404
1/2
✓ Branch 0 taken 9284885 times.
✗ Branch 1 not taken.
9284885 if(CheatModifierKeys())
4405 {
4406 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4407 {
4408 if(!bindable_cheat(c))
4409 continue;
4410 if(get_debug() || cheat >= cheat_lvl(c))
4411 {
4412 if(checkcheat(c))
4413 cheats_hit_bind(c);
4414 }
4415 }
4416 }
4417
4418
1/2
✓ Branch 0 taken 9284885 times.
✗ Branch 1 not taken.
9284885 if(volkeys)
4419 {
4420 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4421
4422 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4423
4424 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4425
4426 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4427 }
4428
4429
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9284885 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9284885 if(!get_debug() || !SystemKeys || replay_is_replaying())
4430 9284885 goto bottom;
4431
4432 if(zc_readkey(KEY_D))
4433 {
4434 details = !details;
4435 rectfill(screen,0,0,319,7,BLACK);
4436 rectfill(screen,0,8,31,239,BLACK);
4437 rectfill(screen,288,8,319,239,BLACK);
4438 rectfill(screen,32,232,287,239,BLACK);
4439 }
4440
4441 if(zc_readkey(KEY_P)) Paused=!Paused;
4442
4443 //if(zc_readkey(KEY_P)) centerHero();
4444 if(zc_readkey(KEY_A))
4445 {
4446 Paused=true;
4447 Advance=true;
4448 }
4449
4450 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4451 #ifndef ALLEGRO_MACOSX
4452 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4453
4454 if(zc_readkey(KEY_F7))
4455 {
4456 Matrix(ss_speed, ss_density, 0);
4457 game_pal();
4458 }
4459 #else
4460 // The reason these are different on Mac in the first place is that
4461 // the OS doesn't let us use F9 and F10...
4462 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4463
4464 if(zc_readkey(KEY_F9))
4465 {
4466 Matrix(ss_speed, ss_density, 0);
4467 game_pal();
4468 }
4469 #endif
4470 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4471 {
4472 //change containers
4473 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4474 {
4475 //magic containers
4476 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4477 {
4478 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4479 }
4480 else
4481 {
4482 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4483 }
4484 }
4485 else
4486 {
4487 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4488 {
4489 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4490 }
4491 else
4492 {
4493 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4494 }
4495 }
4496 }
4497
4498 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4499 {
4500 //change containers
4501 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4502 {
4503 //magic containers
4504 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4505 {
4506 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4507 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4508 //heart containers
4509 }
4510 else
4511 {
4512 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4513 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4514 }
4515 }
4516 else
4517 {
4518 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4519 {
4520 game->set_magic(zc_max(game->get_magic()-1,0));
4521 }
4522 else
4523 {
4524 game->set_life(zc_max(game->get_life()-1,0));
4525 }
4526 }
4527 }
4528
4529 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4530
4531 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4532
4533 verifyBothWeapons();
4534
4535 bottom:
4536
4537
1/2
✓ Branch 0 taken 9284885 times.
✗ Branch 1 not taken.
9284885 if(input_idle(true) > after_time())
4538 {
4539 Matrix(ss_speed, ss_density, 0);
4540 game_pal();
4541 }
4542 9284885 }
4543
4544 708145 void checkQuitKeys()
4545 {
4546 #ifndef ALLEGRO_MACOSX
4547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708145 times.
708145 if(key[KEY_F9]) f_Quit(qRESET);
4548
4549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708145 times.
708145 if(key[KEY_F10]) f_Quit(qEXIT);
4550 #else
4551 if(key[KEY_F7]) f_Quit(qRESET);
4552
4553 if(key[KEY_F8]) f_Quit(qEXIT);
4554 #endif
4555 708145 }
4556
4557 9284885 bool CheatModifierKeys()
4558 {
4559 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4560 // to trigger cheats.
4561
1/2
✓ Branch 0 taken 9284885 times.
✗ Branch 1 not taken.
9284885 if (replay_is_replaying())
4562 9284885 return false;
4563
4564 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4565 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4566 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4567 {
4568 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4569 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4570 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4571 {
4572 return true;
4573 }
4574 }
4575 return false;
4576 9284885 }
4577
4578 //99:05:54, for some reason?
4579 #define OLDMAXTIME 21405240
4580 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4581 #define MAXTIME 1944000000
4582
4583 9285010 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4584 {
4585
2/2
✓ Branch 0 taken 9164887 times.
✓ Branch 1 taken 120123 times.
9285010 if(zcmusic!=NULL)
4586 {
4587 120123 zcmusic_poll();
4588 120123 }
4589
4590 9285010 updatescr(allowwavy);
4591
4592 9285010 Advance=false;
4593
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9285010 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9285010 times.
9285010 while(Paused && !Advance && !Quit)
4594 {
4595 // have to call this, otherwise we'll get an infinite loop
4596 syskeys();
4597 if(allowF6Script)
4598 {
4599 FFCore.runF6Engine();
4600 }
4601 throttleFPS();
4602
4603 #ifdef _WIN32
4604
4605 if(use_dwm_flush)
4606 {
4607 do_DwmFlush();
4608 }
4609
4610 #endif
4611
4612 // to keep music playing
4613 if(zcmusic!=NULL)
4614 {
4615 zcmusic_poll();
4616 }
4617
4618 update_hw_screen();
4619 }
4620
4621
2/2
✓ Branch 0 taken 9284898 times.
✓ Branch 1 taken 112 times.
9285010 if(Quit)
4622 112 return;
4623
4624
3/4
✓ Branch 0 taken 8983938 times.
✓ Branch 1 taken 300960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8983938 times.
9284898 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4625 8983938 game->change_time(1);
4626
4627 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4628
4629 9284898 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4630
2/2
✓ Branch 0 taken 18170 times.
✓ Branch 1 taken 9266728 times.
9284898 if (replay_version_check(0, 16))
4631 9266728 should_reset_down_state = replay_version_check(11, 16);
4632
2/2
✓ Branch 0 taken 6949611 times.
✓ Branch 1 taken 2335287 times.
9284898 if (should_reset_down_state)
4633 {
4634
2/2
✓ Branch 0 taken 42035166 times.
✓ Branch 1 taken 2335287 times.
44370453 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4635 42035166 down_control_states[i] = raw_control_state[i];
4636 2335287 }
4637
4638
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 9284903 times.
9284898 if (replay_is_active())
4639 {
4640
2/2
✓ Branch 0 taken 1270468 times.
✓ Branch 1 taken 8014435 times.
9284903 if (replay_version_check(3))
4641 8014435 replay_poll();
4642
4643
4/4
✓ Branch 0 taken 6946029 times.
✓ Branch 1 taken 2338856 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 6845494 times.
9284903 if (replay_version_check(11) || replay_version_check(6, 8))
4644 2439391 replay_peek_input();
4645 9284885 }
4646
4647 9284898 load_control_called_this_frame = false;
4648
4649 9284898 poll_keyboard();
4650 9284898 update_keys();
4651
4652 9284898 ++frame;
4653
4654
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 9284885 times.
9284898 if (replay_is_replaying())
4655 9284885 replay_do_cheats();
4656 9284898 syskeys();
4657
4658 // The mouse variables can change from the mouse thread at anytime during a frame,
4659 // so save the result at the start so that replaying is consistent.
4660 9284898 script_mouse_x = gui_mouse_x();
4661 9284898 script_mouse_y = gui_mouse_y();
4662 9284898 script_mouse_z = mouse_z;
4663 9284898 script_mouse_b = mouse_b;
4664
4665 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4666 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4667 // approach here means it doesn't matter which call adds the cheat.
4668 9284898 cheats_execute_queued();
4669
4670
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 9284885 times.
9284898 if (replay_is_replaying())
4671 9284885 replay_peek_quit();
4672
2/2
✓ Branch 0 taken 9284885 times.
✓ Branch 1 taken 13 times.
9284898 if (GameFlags & GAMEFLAG_TRYQUIT)
4673 13 replay_step_quit(0);
4674
2/2
✓ Branch 0 taken 2933 times.
✓ Branch 1 taken 9281965 times.
9284898 if(allowF6Script)
4675 9281965 FFCore.runF6Engine();
4676
2/2
✓ Branch 0 taken 9284599 times.
✓ Branch 1 taken 299 times.
9284898 if (Quit)
4677 299 replay_step_quit(Quit);
4678 // Someday... maybe install a Turbo button here?
4679 9284898 throttleFPS();
4680
4681 #ifdef _WIN32
4682
4683 if(use_dwm_flush)
4684 {
4685 do_DwmFlush();
4686 }
4687
4688 #endif
4689
4690 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4691
2/2
✓ Branch 0 taken 68757 times.
✓ Branch 1 taken 9216141 times.
9284898 if(sfxcleanup)
4692 9216141 sfx_cleanup();
4693
4694 9284898 jit_poll();
4695 9285010 }
4696
4697 101 void zapout()
4698 {
4699 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4700 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4701
4702 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4703 101 script_drawing_commands.Clear();
4704
4705 // zap out
4706
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=1; i<=24; i++)
4707 {
4708 2424 draw_fuzzy(i);
4709 2424 advanceframe(true);
4710
4711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4712 {
4713 break;
4714 }
4715 2424 }
4716 101 }
4717
4718 101 void zapin()
4719 {
4720 101 FFCore.warpScriptCheck();
4721 101 draw_screen(tmpscr);
4722 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4723 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4724 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4725
4726 // zap out
4727 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4728
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=24; i>=1; i--)
4729 {
4730 2424 draw_fuzzy(i);
4731 2424 advanceframe(true);
4732
4733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4734 {
4735 break;
4736 }
4737 2424 }
4738 101 }
4739
4740
4741 65 void wavyout(bool showhero)
4742 {
4743 65 draw_screen(tmpscr, showhero);
4744 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4745
4746 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4747 65 clear_to_color(wavebuf,0);
4748 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4749
4750 static PALETTE wavepal;
4751
4752 int32_t ofs;
4753 65 int32_t amplitude=8;
4754
4755 65 int32_t wavelength=4;
4756 65 double palpos=0, palstep=4, palstop=126;
4757
4758 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4759
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4760 {
4761
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4762 {
4763 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4764 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4765 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4766 698880 }
4767
4768 2730 palpos+=palstep;
4769
4770
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4771 {
4772 2730 hw_palette = &wavepal;
4773 2730 update_hw_pal = true;
4774 2730 }
4775 else
4776 {
4777 hw_palette = &RAMpal;
4778 update_hw_pal = true;
4779 }
4780
4781
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4782 {
4783
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4784 {
4785 117411840 ofs=0;
4786
4787
4/4
✓ Branch 0 taken 57308160 times.
✓ Branch 1 taken 60103680 times.
✓ Branch 2 taken 28654080 times.
✓ Branch 3 taken 28654080 times.
117411840 if((j<i)&&(j&1))
4788 {
4789 28654080 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4790 28654080 }
4791
4792 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4793 117411840 }
4794 458640 }
4795
4796 2730 advanceframe(true);
4797
4798 // animate_combos();
4799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4800 break;
4801 2730 }
4802
4803 65 destroy_bitmap(wavebuf);
4804 65 }
4805
4806 65 void wavyin()
4807 {
4808 65 draw_screen(tmpscr);
4809 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4810
4811 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4812 65 clear_to_color(wavebuf,0);
4813 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4814
4815 static PALETTE wavepal;
4816
4817 //Breaks dark rooms.
4818 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4819 /*
4820 loadfullpal();
4821 loadlvlpal(DMaps[currdmap].color);
4822 ringcolor(false);
4823 */
4824 65 refreshpal=false;
4825 int32_t ofs;
4826 65 int32_t amplitude=8;
4827 65 int32_t wavelength=4;
4828 65 double palpos=168, palstep=4, palstop=126;
4829
4830 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4831
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4832 {
4833
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4834 {
4835 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4836 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4837 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4838 698880 }
4839
4840 2730 palpos-=palstep;
4841
4842
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4843 {
4844 2730 hw_palette = &wavepal;
4845 2730 update_hw_pal = true;
4846 2730 }
4847 else
4848 {
4849 hw_palette = &RAMpal;
4850 update_hw_pal = true;
4851 }
4852
4853
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4854 {
4855
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4856 {
4857 117411840 ofs=0;
4858
4859
4/4
✓ Branch 0 taken 59404800 times.
✓ Branch 1 taken 58007040 times.
✓ Branch 2 taken 30051840 times.
✓ Branch 3 taken 29352960 times.
117411840 if((j<(167-i))&&(j&1))
4860 {
4861 29352960 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4862 29352960 }
4863
4864 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4865 117411840 }
4866 458640 }
4867
4868 2730 advanceframe(true);
4869 // animate_combos();
4870
4871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4872 break;
4873 2730 }
4874
4875 65 destroy_bitmap(wavebuf);
4876 65 }
4877
4878 2168 void blackscr(int32_t fcnt,bool showsubscr)
4879 {
4880 2168 reset_pal_cycling();
4881 2168 script_drawing_commands.Clear();
4882
4883 2168 FFCore.warpScriptCheck();
4884 2168 bool showtime = game->should_show_time();
4885
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 64970 times.
67138 while(fcnt>0)
4886 {
4887 64970 clear_bitmap(framebuf);
4888
4889
2/2
✓ Branch 0 taken 25080 times.
✓ Branch 1 taken 39890 times.
64970 if(showsubscr)
4890 {
4891 39890 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4892
3/4
✓ Branch 0 taken 39890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 39140 times.
39890 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4893 {
4894 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4895 750 }
4896 39890 }
4897
4898 64970 advanceframe(true);
4899
4900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64970 times.
64970 if(Quit)
4901 break;
4902
4903 64970 --fcnt;
4904 }
4905 2168 }
4906
4907 1010 void openscreen(int32_t shape)
4908 {
4909 1010 reset_pal_cycling();
4910 1010 black_opening_count=0;
4911
4912
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 910 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
1010 if(COOLSCROLL || shape>-1)
4913 {
4914 910 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4915 910 return;
4916 }
4917 else
4918 {
4919 100 Hero.setDontDraw(true);
4920 100 show_subscreen_dmap_dots=false;
4921 100 show_subscreen_numbers=false;
4922 // show_subscreen_items=false;
4923 100 show_subscreen_life=false;
4924 }
4925
4926 100 int32_t x=128;
4927
4928 100 FFCore.warpScriptCheck();
4929
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8000 times.
8100 for(int32_t i=0; i<80; i++)
4930 {
4931 8000 draw_screen(tmpscr);
4932 //? draw_screen already draws the subscreen -DD
4933 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4934 8000 x=128-(((i*128/80)/8)*8);
4935
4936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(x>0)
4937 {
4938 8000 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4939 8000 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4940 8000 }
4941
4942 8000 advanceframe(true);
4943
4944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(Quit)
4945 {
4946 break;
4947 }
4948 8000 }
4949
4950 100 Hero.setDontDraw(false);
4951 100 show_subscreen_items=true;
4952 100 show_subscreen_dmap_dots=true;
4953 1010 }
4954
4955 void closescreen(int32_t shape)
4956 {
4957 reset_pal_cycling();
4958 black_opening_count=0;
4959
4960 if(COOLSCROLL || shape>-1)
4961 {
4962 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4963 return;
4964 }
4965 else
4966 {
4967 Hero.setDontDraw(true);
4968 show_subscreen_dmap_dots=false;
4969 show_subscreen_numbers=false;
4970 // show_subscreen_items=false;
4971 show_subscreen_life=false;
4972 }
4973
4974 int32_t x=128;
4975
4976 FFCore.warpScriptCheck();
4977 for(int32_t i=79; i>=0; --i)
4978 {
4979 draw_screen(tmpscr);
4980 //? draw_screen already draws the subscreen -DD
4981 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4982 x=128-(((i*128/80)/8)*8);
4983
4984 if(x>0)
4985 {
4986 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4987 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4988 }
4989
4990 advanceframe(true);
4991
4992 if(Quit)
4993 {
4994 break;
4995 }
4996 }
4997
4998 Hero.setDontDraw(false);
4999 show_subscreen_items=true;
5000 show_subscreen_dmap_dots=true;
5001 }
5002
5003 179 int32_t TriforceCount()
5004 {
5005 179 int32_t c=0;
5006
5007
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5008
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5009 1044 ++c;
5010
5011 179 return c;
5012 }
5013
5014 int32_t onCustomGame()
5015 {
5016 int32_t file = getsaveslot();
5017
5018 if(file < 0)
5019 return D_O_K;
5020
5021 bool ret = (custom_game(file)!=0);
5022 return ret ? D_CLOSE : D_O_K;
5023 }
5024
5025 int32_t onContinue()
5026 {
5027 return D_CLOSE;
5028 }
5029
5030 int32_t onEsc() // Unused?? -L
5031 {
5032 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5033 }
5034
5035 int32_t onVsync()
5036 {
5037 Throttlefps = !Throttlefps;
5038 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5039 return D_O_K;
5040 }
5041
5042 int32_t onWinPosSave()
5043 {
5044 SaveWinPos = !SaveWinPos;
5045 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5046 return D_O_K;
5047 }
5048 int32_t onIntegerScaling()
5049 {
5050 scaleForceInteger = !scaleForceInteger;
5051 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5052 return D_O_K;
5053 }
5054 int32_t onStretchGame()
5055 {
5056 stretchGame = !stretchGame;
5057 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5058 return D_O_K;
5059 }
5060
5061 int32_t onClickToFreeze()
5062 {
5063 ClickToFreeze = !ClickToFreeze;
5064 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5065 return D_O_K;
5066 }
5067
5068 int32_t OnSaveZCConfig()
5069 {
5070 if(jwin_alert3(
5071 "Save Configuration",
5072 "Are you sure that you wish to save your present configuration settings?",
5073 "This will overwrite your prior settings!",
5074 NULL,
5075 "&Yes",
5076 "&No",
5077 NULL,
5078 'y',
5079 'n',
5080 0,
5081 get_zc_font(font_lfont)) == 1)
5082 {
5083 save_game_configs();
5084 return D_O_K;
5085 }
5086 else return D_O_K;
5087 }
5088
5089 int32_t OnnClearQuestDir()
5090 {
5091 if(jwin_alert3(
5092 "Clear Current Directory Cache",
5093 "Are you sure that you wish to clear the current cached directory?",
5094 "This will default the current directory to the ROOT for this instance of ZC Player!",
5095 NULL,
5096 "&Yes",
5097 "&No",
5098 NULL,
5099 'y',
5100 'n',
5101 0,
5102 get_zc_font(font_lfont)) == 1)
5103 {
5104 zc_set_config("zeldadx","win_qst_dir","");
5105 flush_config_file();
5106 strcpy(qstdir,"");
5107 #ifdef __EMSCRIPTEN__
5108 em_sync_fs();
5109 #endif
5110 return D_O_K;
5111 }
5112 else return D_O_K;
5113 }
5114
5115
5116 int32_t onConsoleZASM()
5117 {
5118 if ( !zasm_debugger )
5119 {
5120 AlertDialog("WARNING: ZASM Debugger",
5121 "Enabling this will open the ZASM Debugger Console"
5122 "\nThis will likely grind ZC to a halt with lag."
5123 "\nTo make any use of this, it is suggested that you read"
5124 "\nthe documentation for 'void Breakpoint(char[] string);'"
5125 " in 'ZScript_Additions.txt'"
5126 "\nThis is not recommended for normal users,"
5127 " and is only intended for ZC developers,"
5128 "\nor quest developers coding directly in ZASM"
5129 "\nAre you sure that you wish to open the ZASM Debugger?",
5130 [&](bool ret,bool)
5131 {
5132 if(ret)
5133 {
5134 FFCore.ZASMPrint(true);
5135 }
5136 }).show();
5137 return D_O_K;
5138 }
5139 else
5140 {
5141 FFCore.ZASMPrint(false);
5142 return D_O_K;
5143 }
5144 }
5145
5146
5147 int32_t onConsoleZScript()
5148 {
5149 if ( !zscript_debugger )
5150 {
5151 AlertDialog("ZScript Debugger",
5152 "Enabling this will open the ZScript Debugger Console"
5153 "\nThis will display any messages logged by scripts,"
5154 " including script errors."
5155 "\nAre you sure that you wish to open the ZScript Debugger?",
5156 [&](bool ret,bool)
5157 {
5158 if(ret)
5159 {
5160 FFCore.ZScriptConsole(true);
5161 }
5162 }).show();
5163 return D_O_K;
5164 }
5165 else
5166 {
5167 FFCore.ZScriptConsole(false);
5168 return D_O_K;
5169 }
5170 }
5171
5172 int32_t onClrConsoleOnReload()
5173 {
5174 clearConsoleOnReload = !clearConsoleOnReload;
5175 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5176 return D_O_K;
5177 }
5178 int32_t onClrConsoleOnLoad()
5179 {
5180 clearConsoleOnLoad = !clearConsoleOnLoad;
5181 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5182 return D_O_K;
5183 }
5184
5185
5186 int32_t onFrameSkip()
5187 {
5188 FrameSkip = !FrameSkip;
5189 return D_O_K;
5190 }
5191
5192 int32_t onSaveDragResize()
5193 {
5194 SaveDragResize = !SaveDragResize;
5195 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5196 return D_O_K;
5197 }
5198
5199 int32_t onDragAspect()
5200 {
5201 DragAspect = !DragAspect;
5202 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5203 return D_O_K;
5204 }
5205
5206 int32_t onTransLayers()
5207 {
5208 TransLayers = !TransLayers;
5209 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5210 return D_O_K;
5211 }
5212
5213 int32_t onNESquit()
5214 {
5215 NESquit = !NESquit;
5216 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5217 return D_O_K;
5218 }
5219
5220 int32_t onVolKeys()
5221 {
5222 volkeys = !volkeys;
5223 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5224 return D_O_K;
5225 }
5226
5227 int32_t onShowFPS()
5228 {
5229 ShowFPS = !ShowFPS;
5230 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5231 return D_O_K;
5232 }
5233
5234 1095616430 bool is_Fkey(int32_t k)
5235 {
5236
2/2
✓ Branch 0 taken 111418620 times.
✓ Branch 1 taken 984197810 times.
1095616430 switch(k)
5237 {
5238 case KEY_F1:
5239 case KEY_F2:
5240 case KEY_F3:
5241 case KEY_F4:
5242 case KEY_F5:
5243 case KEY_F6:
5244 case KEY_F7:
5245 case KEY_F8:
5246 case KEY_F9:
5247 case KEY_F10:
5248 case KEY_F11:
5249 case KEY_F12:
5250 111418620 return true;
5251 }
5252
5253 984197810 return false;
5254 1095616430 }
5255
5256 void kb_getkey(DIALOG *d);
5257
5258 //Used by all keyboard key settings dialogues.
5259 void kb_clearjoystick(DIALOG *d)
5260 {
5261 d->flags|=D_SELECTED;
5262
5263 jwin_button_proc(MSG_DRAW,d,0);
5264 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5265 // text_mode(vc(11));
5266 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5267 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5268
5269 update_hw_screen(true);
5270
5271 clear_keybuf();
5272 int32_t k = next_press_key();
5273 clear_keybuf();
5274
5275 //shnarf
5276 //47=f1
5277 //59=esc
5278 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5279 // *((int32_t*)d->dp3) = k;
5280 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5281
5282
5283 d->flags&=~D_SELECTED;
5284 }
5285
5286 //Clears key to 0.
5287 //Used by all keyboard key settings dialogues.
5288 void kb_clearkey(DIALOG *d);
5289
5290 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5291 {
5292 switch(msg)
5293 {
5294 case MSG_KEY:
5295 case MSG_CLICK:
5296
5297 kb_clearjoystick(d);
5298
5299 while(gui_mouse_b())
5300 {
5301 clear_keybuf();
5302 rest(1);
5303 }
5304
5305 return D_REDRAW;
5306 }
5307
5308 return jwin_button_proc(msg,d,c);
5309 }
5310
5311 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5312 //Only used in keyboard settings dialogues to clear keys.
5313 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5314
5315 void j_getbtn(DIALOG *d)
5316 {
5317 d->flags|=D_SELECTED;
5318 jwin_button_proc(MSG_DRAW,d,0);
5319 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5320 // text_mode(vc(11));
5321 int32_t y = screen->h/2 - 12;
5322 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5323 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5324 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5325
5326 update_hw_screen(true);
5327
5328 int32_t b = next_press_btn();
5329
5330 if(b>=0)
5331 *((int32_t*)d->dp3) = b;
5332
5333 d->flags&=~D_SELECTED;
5334
5335 if (player)
5336 player->joy_on = TRUE;
5337 }
5338
5339 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5340 {
5341 switch(msg)
5342 {
5343 case MSG_KEY:
5344 case MSG_CLICK:
5345
5346 j_getbtn(d);
5347
5348 while(gui_mouse_b()) {
5349 rest(1);
5350 clear_keybuf();
5351 }
5352
5353 return D_REDRAW;
5354 }
5355
5356 return jwin_button_proc(msg,d,c);
5357 }
5358
5359 //shnarf
5360 extern const char *key_str[];
5361 std::string get_keystr(int key);
5362
5363 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5364 //extern int32_t zcmusic_bufsz;
5365
5366 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5367 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5368
5369 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5370 {
5371 //these are here to bypass compiler warnings about unused arguments
5372 c=c;
5373
5374 if(msg==MSG_DRAW)
5375 {
5376 switch(d->w)
5377 {
5378 case 0:
5379 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5380 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5381 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5382 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5383 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5384 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5385 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5386 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5387 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5388 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5389 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5390 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5391 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5392 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5393 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5394 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5395 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5396 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5397 break;
5398
5399 case 1:
5400 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5401 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5402 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5403 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5404 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5405 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5406 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5407 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5408 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5409 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5410 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5411 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5412 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5413 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5414 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5415 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5416 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5417 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5418 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5419 break;
5420
5421 case 2:
5422 sprintf(str_a," %3d",midi_volume);
5423 sprintf(str_b," %3d",digi_volume);
5424 sprintf(str_l," %3d",emusic_volume);
5425 sprintf(str_m," %3dKB",zcmusic_bufsz);
5426 sprintf(str_r," %3d",sfx_volume);
5427 strcpy(str_s,pan_str[pan_style]);
5428 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5429 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5430 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5431 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5432 break;
5433 }
5434 }
5435
5436 return D_O_K;
5437 }
5438
5439 int32_t set_vol(void *dp3, int32_t d2)
5440 {
5441 switch(((int32_t*)dp3)[0])
5442 {
5443 case 0:
5444 midi_volume = zc_min(d2<<3,255);
5445 break;
5446
5447 case 1:
5448 digi_volume = zc_min(d2<<3,255);
5449 break;
5450
5451 case 2:
5452 emusic_volume = zc_min(d2<<3,255);
5453 break;
5454
5455 case 3:
5456 sfx_volume = zc_min(d2<<3,255);
5457 break;
5458 }
5459
5460 // text_mode(vc(11));
5461 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5462 return D_O_K;
5463 }
5464
5465 int32_t set_pan(void *dp3, int32_t d2)
5466 {
5467 pan_style = vbound(d2,0,3);
5468 // text_mode(vc(11));
5469 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5470 return D_O_K;
5471 }
5472
5473 int32_t set_buf(void *dp3, int32_t d2)
5474 {
5475 // text_mode(vc(11));
5476 zcmusic_bufsz = d2 + 1;
5477 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5478 return D_O_K;
5479 }
5480
5481 static int32_t gamepad_btn_list[] =
5482 {
5483 6,
5484 7,8,9,10,11,12,13,14,15,16,17,
5485 18,19,20,21,22,23,24,25,26,27,28,
5486 29,30,31,32,33,34,35,36,37,38,39,
5487 -1
5488 };
5489
5490 static int32_t gamepad_dirs_list[] =
5491 {
5492 40,41,42,43,
5493 44,45,46,47,
5494 48,49,50,51,
5495 52,53,54,55,
5496 56,
5497 -1
5498 };
5499
5500 static TABPANEL gamepad_tabs[] =
5501 {
5502 // (text)
5503 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5504 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5505 { NULL, 0, NULL, 0, NULL }
5506 };
5507
5508 static DIALOG gamepad_dlg[] =
5509 {
5510 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5511 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5512 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5513 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5514 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5515 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5516 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5517 // 6
5518 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5519 // 7
5520 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5521 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5522 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5523 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5524 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5525 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5526 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5527 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5528 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5529 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5530 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5531 // 18
5532 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5533 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5534 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5535 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5536 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5537 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5538 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5539 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5540 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5541 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5542 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5543 // 29
5544 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5545 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5546 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5547 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5548 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5549 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5550 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5551 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5552 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5553 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5554 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5555 // 40
5556 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5557 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5558 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5559 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5560 // 44
5561 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5562 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5563 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5564 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5565 // 48
5566 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5567 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5568 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5569 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5570 // 52
5571 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5572 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5573 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5574 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5575 // 56
5576 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5577 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5578 };
5579
5580 static int32_t keyboard_keys_list[] =
5581 {
5582 6,7,8,9,10,
5583 11,12,13,14,15,16,17,18,19,20,
5584 21,22,23,24,25,26,27,28,29,30,
5585 31,32,33,34,35,36,37,38,39,40,
5586 -1
5587 };
5588
5589 static int32_t keyboard_dirs_list[] =
5590 {
5591 41,42,43,44,
5592 45,46,47,48,
5593 49,50,51,52,
5594 53,54,55,56,
5595 -1
5596 };
5597
5598 static int32_t keyboard_mods_list[] =
5599 {
5600 57,58,59,60,
5601 61,62,63,64,
5602 65,66,67,68,
5603 69,70,71,72,
5604 -1
5605 };
5606
5607 static TABPANEL keyboard_control_tabs[] =
5608 {
5609 // (text)
5610 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5611 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5612 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5613 { NULL, 0, NULL, 0, NULL }
5614 };
5615
5616 static DIALOG keyboard_control_dlg[] =
5617 {
5618 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5619 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5620 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5621 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5622 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5623 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5624 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5625 // Keys
5626 // 6
5627 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5628 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5629 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5630 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5631 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5632 // 11
5633 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5634 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5635 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5636 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5637 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5638 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5639 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5640 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5641 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5642 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5643 // 21
5644 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5645 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5646 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5647 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5648 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5649 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5650 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5651 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5652 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5653 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5654 // 31
5655 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5656 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5657 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5658 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5659 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5660 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5661 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5662 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5663 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5664 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5665 // Dirs
5666 // 41
5667 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5668 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5669 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5670 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5671 // 45
5672 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5673 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5674 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5675 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5676 // 49
5677 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5678 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5679 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5680 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5681 // 53
5682 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5683 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5684 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5685 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5686 // Mods
5687 // 57
5688 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5689 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5690 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5691 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5692 // 61
5693 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5694 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5695 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5696 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5697 // 65
5698 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5699 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5700 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5701 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5702 // 69
5703 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5704 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5705 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5706 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5707 // 73
5708 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5709 };
5710
5711 /*
5712 int32_t midi_dp[3] = {0,147,104};
5713 int32_t digi_dp[3] = {1,147,120};
5714 int32_t pan_dp[3] = {0,147,136};
5715 int32_t buf_dp[3] = {0,147,152};
5716 */
5717 int32_t midi_dp[3] = {0,0,0};
5718 int32_t digi_dp[3] = {1,0,0};
5719 int32_t emus_dp[3] = {2,0,0};
5720 int32_t buf_dp[3] = {0,0,0};
5721 int32_t sfx_dp[3] = {3,0,0};
5722 int32_t pan_dp[3] = {0,0,0};
5723
5724 static DIALOG sound_dlg[] =
5725 {
5726 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5727 45 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5728 45 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5729 45 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5730 45 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5731 45 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5732 45 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5733 45 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5734 45 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5735 45 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5736 45 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5737 // 10
5738 45 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5739 45 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5740 45 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5741 45 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5742 45 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5743 45 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5744 45 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5745 45 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5746 45 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5747 45 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5748 //20
5749 45 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5750 45 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5751 45 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5752 45 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5753 45 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5754 45 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5755 45 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5756 45 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5757 45 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5758 45 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5759 //30
5760 45 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5761 45 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5762 45 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5763 45 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5764 };
5765
5766 char zc_builddate[80];
5767 char zc_aboutstr[80];
5768
5769 static DIALOG about_dlg[] =
5770 {
5771 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5772 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5773 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5774 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5775 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5776 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5777 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5778 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5779 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5780 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5781 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5782 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5783 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5784 };
5785
5786
5787 static DIALOG quest_dlg[] =
5788 {
5789 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5790 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5791 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5792 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5793 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5794 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5795 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5796 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5797 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5798 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5799 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5800 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5801 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5802 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5803 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5804 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5805 };
5806
5807 static DIALOG triforce_dlg[] =
5808 {
5809 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5810 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5811 // 1
5812 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5813 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5814 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5815 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5816 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5817 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5818 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5819 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5820 // 9
5821 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5822 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5823 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5824 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5825 };
5826
5827 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5828 {
5829 go();
5830 int32_t ret=0;
5831 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5832 comeback();
5833 return ret != 0;
5834 }
5835
5836
5837 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5838 {
5839 if(def!=modulepath)
5840 strcpy(modulepath,def);
5841
5842 if(!usefilename)
5843 {
5844 int32_t i=(int32_t)strlen(modulepath);
5845
5846 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5847 modulepath[i--]=0;
5848 }
5849
5850 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5851 int32_t ret=0;
5852 int32_t sel=0;
5853
5854 if(list==NULL)
5855 {
5856 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
5857 }
5858 else
5859 {
5860 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
5861 }
5862
5863 return ret!=0;
5864 }
5865
5866 //The Dialogue that loads a ZMOD Module File
5867 int32_t zc_load_zmod_module_file()
5868 {
5869 if ( Playing )
5870 {
5871 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5872 return -1;
5873 }
5874 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
5875 return D_CLOSE;
5876
5877 FILE *tempmodule = fopen(modulepath,"r");
5878
5879 if(tempmodule == NULL)
5880 {
5881 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5882 return -1;
5883 }
5884
5885
5886 //Set the module path:
5887 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
5888 strcpy(moduledata.module_name, modulepath);
5889 al_trace("New Module Path is: %s \n", moduledata.module_name);
5890 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
5891 zcm.init(true); //Load the module values.
5892 moduledata.refresh_title_screen = 1;
5893 // refresh_select_screen = 1;
5894 build_biic_list();
5895 return D_O_K;
5896 }
5897
5898 static DIALOG module_info_dlg[] =
5899 {
5900 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
5901
5902
5903 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
5904 //1
5905 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
5906 //2
5907 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5908 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
5909 //4
5910 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5911 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5912 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
5913 //7
5914
5915 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5916 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5917 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5918 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5919 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5920 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5921 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5922 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5923 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5924
5925 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5926 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5927 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5928 };
5929
5930 void about_zcplayer_module(const char *prompt,int32_t initialval)
5931 {
5932
5933 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
5934 if ( moduledata.moduletitle[0] != 0 )
5935 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
5936
5937 if ( moduledata.moduleauthor[0] != 0 )
5938 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
5939
5940 if ( moduledata.moduleinfo0[0] != 0 )
5941 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
5942 if ( moduledata.moduleinfo1[0] != 0 )
5943 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
5944 if ( moduledata.moduleinfo2[0] != 0 )
5945 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
5946 if ( moduledata.moduleinfo3[0] != 0 )
5947 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
5948 if ( moduledata.moduleinfo4[0] != 0 )
5949 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
5950
5951 char module_date[255];
5952 memset(module_date, 0, sizeof(module_date));
5953 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
5954 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
5955
5956
5957
5958 char module_vers[255];
5959 memset(module_vers, 0, sizeof(module_vers));
5960 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
5961
5962
5963 //sprintf(tilecount,"%d",1);
5964
5965 char module_build[255];
5966 memset(module_build, 0, sizeof(module_build));
5967 if ( moduledata.modbeta )
5968 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
5969 else
5970 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
5971
5972 module_info_dlg[12].dp = (char*)module_date;
5973 module_info_dlg[13].dp = (char*)module_vers;
5974 module_info_dlg[14].dp = (char*)module_build;
5975
5976 large_dialog(module_info_dlg);
5977
5978 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
5979 jwin_center_dialog(module_info_dlg);
5980
5981
5982 }
5983
5984 int32_t onAbout_ZCP_Module()
5985 {
5986 about_zcplayer_module("About Module (.zmod)", 0);
5987 return D_O_K;
5988 }
5989
5990 //New Modules Menu for 2.55+
5991 static MENU zcmodule_menu[] =
5992 {
5993 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
5994 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
5995
5996 { NULL, NULL, NULL, 0, NULL }
5997 };
5998
5999 int32_t onToggleRecordingNewSaves()
6000 {
6001 if (zc_get_config("zeldadx", "replay_new_saves", false))
6002 {
6003 zc_set_config("zeldadx", "replay_new_saves", false);
6004 }
6005 else
6006 {
6007 zc_set_config("zeldadx", "replay_new_saves", true);
6008 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6009 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6010 }
6011 return D_O_K;
6012 }
6013
6014 int32_t onToggleSnapshotAllFrames()
6015 {
6016 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6017 return D_O_K;
6018 }
6019
6020 int32_t onStopReplayOrRecord()
6021 {
6022 if (replay_is_replaying())
6023 {
6024 replay_quit();
6025 }
6026 else if (replay_get_mode() == ReplayMode::Record)
6027 {
6028 if (!replay_get_meta_bool("test_mode"))
6029 {
6030 jwin_alert("Recording", "You cannot stop recording a save file.",
6031 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6032 return D_CLOSE;
6033 }
6034
6035 if (jwin_alert("Stop Recording",
6036 "Save replay to disk and stop recording?",
6037 "This will stop the recording.",
6038 NULL,
6039 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6040 return D_CLOSE;
6041
6042 replay_save();
6043 replay_stop();
6044 }
6045 return D_O_K;
6046 }
6047
6048 static int32_t handle_on_load_replay(ReplayMode mode)
6049 {
6050 if (Playing)
6051 {
6052 if (jwin_alert("Replay - Warning!",
6053 "Loading a replay will exit the current game.",
6054 "All unsaved progress will be lost.",
6055 "Do you wish to continue?",
6056 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6057 return D_CLOSE;
6058 }
6059
6060 std::string mode_string = replay_mode_to_string(mode);
6061 mode_string[0] = std::toupper(mode_string[0]);
6062
6063 std::string line_1 = "Select a replay file to play back.";
6064 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6065 std::string line_3 = "You can stop the replay and take over manually any time.";
6066 if (mode == ReplayMode::Update)
6067 {
6068 line_1 = "Select a replay file to update.";
6069 line_2 = "WARNING: be sure to back up the zplay file";
6070 line_3 = "and verify that the updated replay works as expected!";
6071 }
6072
6073 if (jwin_alert(mode_string.c_str(),
6074 line_1.c_str(),
6075 line_2.c_str(),
6076 line_3.c_str(),
6077 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6078 {
6079 char replay_path[2048];
6080 strcpy(replay_path, "replays/");
6081 if (jwin_file_select_ex(
6082 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6083 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6084 return D_CLOSE;
6085
6086 replay_quit();
6087 load_replay_file_deferred(mode, replay_path);
6088 Quit = qRESET;
6089 return D_CLOSE;
6090 }
6091 return D_O_K;
6092 }
6093
6094 int32_t onLoadReplay()
6095 {
6096 return handle_on_load_replay(ReplayMode::Replay);
6097 }
6098
6099 int32_t onLoadReplayAssert()
6100 {
6101 return handle_on_load_replay(ReplayMode::Assert);
6102 }
6103
6104 int32_t onLoadReplayUpdate()
6105 {
6106 return handle_on_load_replay(ReplayMode::Update);
6107 }
6108
6109 int32_t onSaveReplay()
6110 {
6111 if (replay_get_mode() == ReplayMode::Record)
6112 {
6113 if (!replay_get_meta_bool("test_mode"))
6114 {
6115 if (jwin_alert("Save Replay",
6116 "This will save a copy of the replay up to this point.",
6117 "The official replay file will be untouched.",
6118 "Do you wish to continue?",
6119 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6120 return D_CLOSE;
6121
6122 char replay_path[2048];
6123 strcpy(replay_path, replay_get_replay_path().string().c_str());
6124 if (jwin_file_select_ex(
6125 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6126 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6127 return D_CLOSE;
6128
6129 if (fileexists(replay_path))
6130 {
6131 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6132 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6133 return D_CLOSE;
6134 }
6135
6136 replay_save(replay_path);
6137 }
6138 else
6139 {
6140 replay_save();
6141 }
6142 }
6143 return D_O_K;
6144 }
6145
6146 static MENU replay_menu[] =
6147 {
6148 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6149 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6150 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6151 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6152 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6153 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6154 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6155
6156 { NULL, NULL, NULL, 0, NULL }
6157 };
6158
6159 static DIALOG credits_dlg[] =
6160 {
6161 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6162 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6163 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6164 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6165 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6166 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6167 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6168 };
6169
6170 45 static ListData dmap_list(dmaplist, &font);
6171
6172 static DIALOG goto_dlg[] =
6173 {
6174 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6175 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6176 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6177 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6178 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6179 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6180 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6181 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6182 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6183 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6184 };
6185
6186 int32_t onGoTo()
6187 {
6188 bool music = false;
6189 music = music;
6190 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6191
6192 goto_dlg[0].dp2=get_zc_font(font_lfont);
6193 goto_dlg[4].d2=cheat_goto_dmap;
6194 goto_dlg[6].dp=cheat_goto_screen_str;
6195
6196 clear_keybuf();
6197
6198 large_dialog(goto_dlg);
6199
6200 if(zc_popup_dialog(goto_dlg,4)==1)
6201 {
6202 // dmap, screen
6203 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6204 };
6205
6206 return D_O_K;
6207 }
6208
6209 int32_t onGoToComplete()
6210 {
6211 if(!Playing)
6212 {
6213 return D_O_K;
6214 }
6215
6216 enter_sys_pal();
6217 music_pause();
6218 pause_all_sfx();
6219 onGoTo();
6220 eat_buttons();
6221
6222 zc_readrawkey(KEY_ESC);
6223
6224 exit_sys_pal();
6225 music_resume();
6226 resume_all_sfx();
6227 return D_O_K;
6228 }
6229
6230 int32_t onCredits()
6231 {
6232 go();
6233
6234 BITMAP *win = create_bitmap_ex(8,222,110);
6235
6236 if(!win)
6237 return D_O_K;
6238
6239 int32_t c=0;
6240 int32_t l=0;
6241 int32_t ol=-1;
6242 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6243 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6244 PALETTE tmppal;
6245
6246 rti_gui.transparency_index = 1;
6247
6248 clear_to_color(win, rti_gui.transparency_index);
6249 draw_rle_sprite(win,rle,0,0);
6250 credits_dlg[0].dp2=get_zc_font(font_lfont);
6251 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6252 credits_dlg[2].dp = win;
6253
6254 zc_set_palette_range(black_palette,0,127,false);
6255
6256 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6257
6258 BITMAP* old_screen = screen;
6259 BITMAP* gui_bmp = zc_get_gui_bmp();
6260 ASSERT(gui_bmp);
6261 clear_to_color(gui_bmp, rti_gui.transparency_index);
6262 screen = gui_bmp;
6263
6264 while(update_dialog(p))
6265 {
6266 throttleFPS();
6267 ++c;
6268 l = zc_max((c>>1)-30,0);
6269
6270 if(l > rle->h)
6271 l = c = 0;
6272
6273 if(l > rle->h - 112)
6274 l = rle->h - 112;
6275
6276 clear_bitmap(win);
6277 draw_rle_sprite(win,rle,0,0-l);
6278
6279 if(c<=64)
6280 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6281
6282 zc_set_palette_range(tmppal,0,127,false);
6283
6284 if(l!=ol)
6285 {
6286 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6287 SCRFIX();
6288 ol=l;
6289 }
6290
6291 update_hw_screen();
6292 }
6293
6294 screen = old_screen;
6295 system_pal(true);
6296 sys_mouse();
6297
6298 shutdown_dialog(p);
6299 destroy_bitmap(win);
6300 //comeback();
6301
6302 rti_gui.transparency_index = 0;
6303 clear_to_color(gui_bmp, rti_gui.transparency_index);
6304
6305 return D_O_K;
6306 }
6307
6308 const char *midilist(int32_t index, int32_t *list_size)
6309 {
6310 if(index<0)
6311 {
6312 *list_size=0;
6313
6314 for(int32_t i=0; i<MAXMIDIS; i++)
6315 if(tunes[i].data)
6316 ++(*list_size);
6317
6318 return NULL;
6319 }
6320
6321 int32_t i=0,m=0;
6322
6323 while(m<=index && i<=MAXMIDIS)
6324 {
6325 if(tunes[i].data)
6326 ++m;
6327
6328 ++i;
6329 }
6330
6331 --i;
6332
6333 if(i==MAXMIDIS && m<index)
6334 return "(null)";
6335
6336 return tunes[i].title;
6337 }
6338
6339 /* ------- MIDI info stuff -------- */
6340
6341 char *text;
6342 midi_info *zmi;
6343 bool dialog_running;
6344 bool listening;
6345
6346 void get_info(int32_t index);
6347
6348 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6349 {
6350 int32_t d2 = d->d2;
6351 int32_t ret = jwin_droplist_proc(msg,d,c);
6352
6353 if(d2!=d->d2)
6354 {
6355 get_info(d->d2);
6356 }
6357
6358 return ret;
6359 }
6360
6361 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6362 {
6363 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6364
6365 int32_t ret = jwin_button_proc(msg,d,c);
6366
6367 if(ret == D_CLOSE)
6368 {
6369 // get current midi index
6370 int32_t index = (d+(d->d1))->d2;
6371 int32_t i=0, m=0;
6372
6373 while(m<=index && i<=MAXMIDIS)
6374 {
6375 if(tunes[i].data)
6376 ++m;
6377
6378 ++i;
6379 }
6380
6381 --i;
6382 jukebox(i);
6383 listening = true;
6384 ret = D_O_K;
6385 }
6386
6387 return ret;
6388 }
6389
6390 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6391 {
6392 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6393
6394 int32_t ret = jwin_button_proc(msg,d,c);
6395
6396 if(ret == D_CLOSE)
6397 {
6398 // get current midi index
6399 int32_t index = (d+(d->d1))->d2;
6400 int32_t i=0, m=0;
6401
6402 while(m<=index && i<=MAXMIDIS)
6403 {
6404 if(tunes[i].data)
6405 ++m;
6406
6407 ++i;
6408 }
6409
6410 --i;
6411
6412 // get file name
6413
6414 int32_t sel=0;
6415 //struct ffblk f;
6416 char title[40] = "Save MIDI: ";
6417 char fname[2048];
6418 memset(fname,0,2048);
6419 static EXT_LIST list[] =
6420 {
6421 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6422 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6423 { NULL, NULL }
6424 };
6425
6426 strcpy(title+11, tunes[i].title);
6427 title[39] = '\0';
6428
6429 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6430 goto done;
6431
6432 if(exists(fname))
6433 {
6434 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6435 goto done;
6436 }
6437
6438 // save midi i
6439
6440 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6441 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6442
6443 done:
6444 chop_path(fname);
6445 ret = D_REDRAW;
6446 }
6447
6448 return ret;
6449 }
6450
6451 45 static ListData midi_list(midilist, &font);
6452
6453 static DIALOG midi_dlg[] =
6454 {
6455 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6456 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6457 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6458 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6459 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6460 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6461 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6462 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6463 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6464 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6465 };
6466
6467 void get_info(int32_t index)
6468 {
6469 int32_t i=0, m=0;
6470
6471 while(m<=index && i<=MAXMIDIS)
6472 {
6473 if(tunes[i].data)
6474 ++m;
6475
6476 ++i;
6477 }
6478
6479 --i;
6480
6481 if(i==MAXMIDIS && m<index)
6482 strcpy(text,"(null)");
6483 else
6484 {
6485 get_midi_info((MIDI*)tunes[i].data,zmi);
6486 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6487 }
6488
6489 midi_dlg[0].dp2=get_zc_font(font_lfont);
6490 midi_dlg[3].dp = text;
6491 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6492 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6493
6494 if(dialog_running)
6495 {
6496 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6497 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6498 }
6499 }
6500
6501 int32_t onMIDICredits()
6502 {
6503 text = (char*)malloc(4096);
6504 zmi = (midi_info*)malloc(sizeof(midi_info));
6505
6506 if(!text || !zmi)
6507 {
6508 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6509 return D_O_K;
6510 }
6511
6512 bool do_pause_midi = midi_pos >= 0 && currmidi;
6513 auto restore_midi = currmidi;
6514 if(do_pause_midi)
6515 {
6516 paused_midi_pos = midi_pos;
6517 stop_midi();
6518 midi_suspended = midissuspHALTED;
6519 }
6520
6521 midi_dlg[0].dp2=get_zc_font(font_lfont);
6522 midi_dlg[2].d1 = 0;
6523 midi_dlg[2].d2 = 0;
6524 midi_dlg[4].flags = D_EXIT;
6525 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6526
6527 listening = false;
6528 dialog_running=false;
6529 get_info(0);
6530
6531 dialog_running=true;
6532
6533 large_dialog(midi_dlg);
6534
6535 zc_popup_dialog(midi_dlg,0);
6536 dialog_running=false;
6537
6538 if(listening)
6539 music_stop();
6540
6541 if(do_pause_midi)
6542 {
6543 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6544 midi_suspended = midissuspRESUME;
6545 currmidi = restore_midi;
6546 midi_pos = paused_midi_pos;
6547 }
6548
6549 if(text) free(text);
6550 if(zmi) free(zmi);
6551 return D_O_K;
6552 }
6553
6554 int32_t onAbout()
6555 {
6556 char buf1[80]={0};
6557 std::ostringstream oss;
6558 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6559 oss << buf1 << '\n';
6560 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6561 oss << buf1 << '\n';
6562 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6563 oss << buf1 << '\n';
6564 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6565 oss << buf1 << '\n';
6566 sprintf(buf1, "Tag: %s", getReleaseTag());
6567 oss << buf1 << '\n';
6568
6569 InfoDialog("About ZC", oss.str()).show();
6570 return D_O_K;
6571 }
6572
6573 int32_t onQuest()
6574 {
6575 char fname[100];
6576 strcpy(fname, get_filename(qstpath));
6577 quest_dlg[0].dp2=get_zc_font(font_lfont);
6578 quest_dlg[1].dp = fname;
6579
6580 if(QHeader.quest_number==0)
6581 sprintf(str_a,"Custom");
6582 else
6583 sprintf(str_a,"%d",QHeader.quest_number);
6584
6585 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6586
6587 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6588 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6589
6590 large_dialog(quest_dlg);
6591
6592 zc_popup_dialog(quest_dlg, 0);
6593 return D_O_K;
6594 }
6595
6596 void call_vidmode_dlg();
6597 int32_t onVidMode()
6598 {
6599 call_vidmode_dlg();
6600 return D_O_K;
6601 }
6602
6603 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6604 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6605 //Added an extra statement, so that if the key is cleared to 0, the cleared
6606 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6607
6608 void load_ukeys(int32_t* arr)
6609 {
6610 arr[ukey_a] = Akey;
6611 arr[ukey_b] = Bkey;
6612 arr[ukey_s] = Skey;
6613 arr[ukey_l] = Lkey;
6614 arr[ukey_r] = Rkey;
6615 arr[ukey_p] = Pkey;
6616 arr[ukey_ex1] = Exkey1;
6617 arr[ukey_ex2] = Exkey2;
6618 arr[ukey_ex3] = Exkey3;
6619 arr[ukey_ex4] = Exkey4;
6620 arr[ukey_du] = DUkey;
6621 arr[ukey_dd] = DDkey;
6622 arr[ukey_dl] = DLkey;
6623 arr[ukey_dr] = DRkey;
6624 arr[ukey_mod1a] = cheat_modifier_keys[0];
6625 arr[ukey_mod1b] = cheat_modifier_keys[1];
6626 arr[ukey_mod2a] = cheat_modifier_keys[2];
6627 arr[ukey_mod2b] = cheat_modifier_keys[3];
6628 };
6629
6630 static const char* ukey_names[] = {
6631 "A", "B", "Start", "L", "R", "Map",
6632 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6633 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6634 "Cheat Mod R1", "Cheat Mod R2",
6635 };
6636 std::string get_ukey_name(int32_t k)
6637 {
6638 if (k < num_ukey) return ukey_names[k];
6639 return "";
6640 }
6641
6642 int32_t onKeyboard()
6643 {
6644 int32_t a = Akey;
6645 int32_t b = Bkey;
6646 int32_t s = Skey;
6647 int32_t l = Lkey;
6648 int32_t r = Rkey;
6649 int32_t p = Pkey;
6650 int32_t ex1 = Exkey1;
6651 int32_t ex2 = Exkey2;
6652 int32_t ex3 = Exkey3;
6653 int32_t ex4 = Exkey4;
6654 int32_t du = DUkey;
6655 int32_t dd = DDkey;
6656 int32_t dl = DLkey;
6657 int32_t dr = DRkey;
6658 int32_t mod1a = cheat_modifier_keys[0];
6659 int32_t mod1b = cheat_modifier_keys[1];
6660 int32_t mod2a = cheat_modifier_keys[2];
6661 int32_t mod2b = cheat_modifier_keys[3];
6662 bool done=false;
6663 int32_t ret;
6664
6665 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6666
6667 large_dialog(keyboard_control_dlg);
6668
6669 while(!done)
6670 {
6671 ret = zc_popup_dialog(keyboard_control_dlg,3);
6672
6673 if(ret==3) // OK
6674 {
6675 int32_t ukeys[num_ukey];
6676 load_ukeys(ukeys);
6677 std::vector<std::string> uniqueError;
6678 for(int32_t q = 0; q < num_ukey; ++q)
6679 {
6680 for(int32_t p = q+1; p < num_ukey; ++p)
6681 {
6682 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6683 {
6684 char buf[64];
6685 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6686 std::string str(buf);
6687 uniqueError.push_back(str);
6688 }
6689 }
6690 }
6691 if(uniqueError.size() == 0)
6692 {
6693 done = true;
6694 save_control_configs(true);
6695 }
6696 else
6697 {
6698 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6699 box_out("Cannot have duplicate keybinds!"); box_eol();
6700 for(std::vector<std::string>::iterator it = uniqueError.begin();
6701 it != uniqueError.end(); ++it)
6702 {
6703 box_out((*it).c_str()); box_eol();
6704 }
6705 box_end(true);
6706 }
6707 }
6708 else // Cancel
6709 {
6710 Akey = a;
6711 Bkey = b;
6712 Skey = s;
6713 Lkey = l;
6714 Rkey = r;
6715 Pkey = p;
6716 Exkey1 = ex1;
6717 Exkey2 = ex2;
6718 Exkey3 = ex3;
6719 Exkey4 = ex4;
6720 DUkey = du;
6721 DDkey = dd;
6722 DLkey = dl;
6723 DRkey = dr;
6724 cheat_modifier_keys[0] = mod1a;
6725 cheat_modifier_keys[1] = mod1b;
6726 cheat_modifier_keys[2] = mod2a;
6727 cheat_modifier_keys[3] = mod2b;
6728
6729 done=true;
6730 }
6731
6732 rest(1);
6733 }
6734
6735 return D_O_K;
6736 }
6737
6738 int32_t onGamepad()
6739 {
6740 int32_t a = Abtn;
6741 int32_t b = Bbtn;
6742 int32_t s = Sbtn;
6743 int32_t l = Lbtn;
6744 int32_t r = Rbtn;
6745 int32_t m = Mbtn;
6746 int32_t p = Pbtn;
6747 int32_t ex1 = Exbtn1;
6748 int32_t ex2 = Exbtn2;
6749 int32_t ex3 = Exbtn3;
6750 int32_t ex4 = Exbtn4;
6751 int32_t up = DUbtn;
6752 int32_t down = DDbtn;
6753 int32_t left = DLbtn;
6754 int32_t right = DRbtn;
6755
6756 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6757 if(analog_movement)
6758 gamepad_dlg[56].flags|=D_SELECTED;
6759 else
6760 gamepad_dlg[56].flags&=~D_SELECTED;
6761
6762 large_dialog(gamepad_dlg);
6763
6764 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6765
6766 if(ret == 4) //OK
6767 {
6768 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6769 save_control_configs(false);
6770 }
6771 else //Cancel
6772 {
6773 Abtn = a;
6774 Bbtn = b;
6775 Sbtn = s;
6776 Lbtn = l;
6777 Rbtn = r;
6778 Mbtn = m;
6779 Pbtn = p;
6780 Exbtn1 = ex1;
6781 Exbtn2 = ex2;
6782 Exbtn3 = ex3;
6783 Exbtn4 = ex4;
6784 DUbtn = up;
6785 DDbtn = down;
6786 DLbtn = left;
6787 DRbtn = right;
6788 }
6789
6790 return D_O_K;
6791 }
6792
6793 int32_t onCheatKeys()
6794 {
6795 int32_t oldcheats[Cheat::Last][2];
6796 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6797
6798 bool done=false;
6799
6800 while(!done)
6801 {
6802 bool confirm = false;
6803 CheatKeysDialog(&confirm).show();
6804 if(confirm) // OK
6805 {
6806 std::vector<std::string> uniqueError;
6807 char buf[512];
6808 for(size_t q = 1; q < Cheat::Last; ++q)
6809 {
6810 if(cheatkeys[q][1] && !cheatkeys[q][0])
6811 {
6812 cheatkeys[q][0] = cheatkeys[q][1];
6813 cheatkeys[q][1] = 0;
6814 }
6815 }
6816 for(size_t q = 1; q < Cheat::Last; ++q)
6817 {
6818 if(!bindable_cheat((Cheat)q)) continue;
6819 for(size_t p = q+1; p < Cheat::Last; ++p)
6820 {
6821 if(!bindable_cheat((Cheat)p)) continue;
6822 for(size_t q2 = 0; q2 <= 1; ++q2)
6823 for(size_t p2 = 0; p2 <= 1; ++p2)
6824 {
6825 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6826 {
6827 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6828 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6829 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6830 get_keystr(cheatkeys[q][q2])));
6831 }
6832 }
6833 }
6834 }
6835 if(uniqueError.size() == 0)
6836 {
6837 done = true;
6838 save_cheatkeys();
6839 }
6840 else
6841 {
6842 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6843 box_out("Cannot have duplicate keybinds!"); box_eol();
6844 for(std::vector<std::string>::iterator it = uniqueError.begin();
6845 it != uniqueError.end(); ++it)
6846 {
6847 box_out((*it).c_str()); box_eol();
6848 }
6849 box_end(true);
6850 }
6851 }
6852 else // Cancel
6853 {
6854 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6855 done=true;
6856 }
6857 rest(1);
6858 }
6859
6860 return D_O_K;
6861 }
6862
6863 int32_t onSound()
6864 {
6865 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
6866 {
6867 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
6868 }
6869 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
6870 {
6871 master_volume((int32_t)(FFCore.usr_digi_volume),1);
6872 }
6873 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
6874 {
6875 emusic_volume = (int32_t)FFCore.usr_music_volume;
6876 }
6877 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
6878 {
6879 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6880 }
6881 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6882 {
6883 pan_style = (int32_t)FFCore.usr_panstyle;
6884 }
6885
6886 int32_t m = midi_volume;
6887 int32_t d = digi_volume;
6888 int32_t e = emusic_volume;
6889 int32_t b = zcmusic_bufsz;
6890 int32_t s = sfx_volume;
6891 int32_t p = pan_style;
6892 pan_style = vbound(pan_style,0,3);
6893
6894 sound_dlg[0].dp2=get_zc_font(font_lfont);
6895
6896 large_dialog(sound_dlg);
6897
6898 midi_dp[1] = sound_dlg[6].x;
6899 midi_dp[2] = sound_dlg[6].y;
6900 digi_dp[1] = sound_dlg[7].x;
6901 digi_dp[2] = sound_dlg[7].y;
6902 emus_dp[1] = sound_dlg[8].x;
6903 emus_dp[2] = sound_dlg[8].y;
6904 buf_dp[1] = sound_dlg[9].x;
6905 buf_dp[2] = sound_dlg[9].y;
6906 sfx_dp[1] = sound_dlg[10].x;
6907 sfx_dp[2] = sound_dlg[10].y;
6908 pan_dp[1] = sound_dlg[11].x;
6909 pan_dp[2] = sound_dlg[11].y;
6910 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6911 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6912 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6913 sound_dlg[18].d2 = zcmusic_bufsz;
6914 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6915 sound_dlg[20].d2 = pan_style;
6916
6917 int32_t ret = zc_popup_dialog(sound_dlg,1);
6918
6919 if(ret==2)
6920 {
6921 master_volume(digi_volume,midi_volume);
6922 if (zcmusic)
6923 zcmusic_set_volume(zcmusic, emusic_volume);
6924
6925 for(int32_t i=0; i<WAV_COUNT; ++i)
6926 {
6927 //allegro assertion fails when passing in -1 as voice -DD
6928 if(sfx_voice[i] > 0)
6929 voice_set_volume(sfx_voice[i], sfx_volume);
6930 }
6931 zc_set_config(sfx_sect,"digi",digi_volume);
6932 zc_set_config(sfx_sect,"midi",midi_volume);
6933 zc_set_config(sfx_sect,"sfx",sfx_volume);
6934 zc_set_config(sfx_sect,"emusic",emusic_volume);
6935 zc_set_config(sfx_sect,"pan",pan_style);
6936 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
6937 }
6938 else
6939 {
6940 midi_volume = m;
6941 digi_volume = d;
6942 emusic_volume = e;
6943 zcmusic_bufsz = b;
6944 sfx_volume = s;
6945 pan_style = p;
6946 }
6947
6948 return D_O_K;
6949 }
6950
6951 int32_t queding(char const* s1, char const* s2, char const* s3)
6952 {
6953 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6954 }
6955
6956 int32_t onQuit()
6957 {
6958 if(Playing)
6959 {
6960 int32_t ret=0;
6961
6962 if(get_qr(qr_NOCONTINUE))
6963 {
6964 if(standalone_mode)
6965 {
6966 ret=queding("End current game?",
6967 "The continue screen is disabled; the game",
6968 "will be reloaded from the last save.");
6969 }
6970 else
6971 {
6972 ret=queding("End current game?",
6973 "The continue screen is disabled. You will",
6974 "be returned to the file select screen.");
6975 }
6976 }
6977 else
6978 ret=queding("End current game?",NULL,NULL);
6979
6980 if(ret==1)
6981 {
6982 disableClickToFreeze=false;
6983 Quit=qQUIT;
6984
6985 // Trying to evade a door repair charge?
6986 if(repaircharge)
6987 {
6988 game->change_drupy(-repaircharge);
6989 repaircharge=0;
6990 }
6991
6992 return D_CLOSE;
6993 }
6994 }
6995
6996 return D_O_K;
6997 }
6998
6999 int32_t onTryQuitMenu()
7000 {
7001 return onTryQuit(true);
7002 }
7003
7004 int32_t onTryQuit(bool inMenu)
7005 {
7006 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7007 {
7008 if(active_cutscene.can_f6())
7009 {
7010 if(get_qr(qr_OLD_F6))
7011 {
7012 if(inMenu) onQuit();
7013 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
7014 }
7015 else
7016 {
7017 disableClickToFreeze=false;
7018 GameFlags |= GAMEFLAG_TRYQUIT;
7019 }
7020 return D_CLOSE;
7021 }
7022 else active_cutscene.error();
7023 }
7024
7025 return D_O_K;
7026 }
7027
7028 int32_t onReset()
7029 {
7030 if(queding(" Reset system? ",NULL,NULL)==1)
7031 {
7032 disableClickToFreeze=false;
7033 Quit=qRESET;
7034 replay_quit();
7035 return D_CLOSE;
7036 }
7037
7038 return D_O_K;
7039 }
7040
7041 int32_t onExit()
7042 {
7043 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
7044 {
7045 Quit=qEXIT;
7046 return D_CLOSE;
7047 }
7048
7049 return D_O_K;
7050 }
7051
7052 int32_t onTitle_NES()
7053 {
7054 title_version=0;
7055 zc_set_config(cfg_sect,"title",title_version);
7056 return D_O_K;
7057 }
7058 int32_t onTitle_DX()
7059 {
7060 title_version=1;
7061 zc_set_config(cfg_sect,"title",title_version);
7062 return D_O_K;
7063 }
7064 int32_t onTitle_25()
7065 {
7066 title_version=2;
7067 zc_set_config(cfg_sect,"title",title_version);
7068 return D_O_K;
7069 }
7070
7071 int32_t onDebug()
7072 {
7073 if(debug_enabled)
7074 set_debug(!get_debug());
7075 return D_O_K;
7076 }
7077
7078 int32_t onHeartBeep()
7079 {
7080 heart_beep=!heart_beep;
7081 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7082 return D_O_K;
7083 }
7084
7085 int32_t onSaveIndicator()
7086 {
7087 use_save_indicator = use_save_indicator ? 0 : 1;
7088 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7089 return D_O_K;
7090 }
7091
7092 int32_t onEpilepsy()
7093 {
7094 if(jwin_alert3(
7095 "Epilepsy Flash Reduction",
7096 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7097 "Disabling this will restore standard flash and wavy behaviour.",
7098 "Proceed?",
7099 "&Yes",
7100 "&No",
7101 NULL,
7102 'y',
7103 'n',
7104 0,
7105 get_zc_font(font_lfont)) == 1)
7106 {
7107 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7108 zc_set_config("zeldadx","checked_epilepsy",1);
7109 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7110 }
7111 return D_O_K;
7112 }
7113
7114 int32_t onTriforce()
7115 {
7116 for(int32_t i=0; i<MAXINITTABS; ++i)
7117 {
7118 init_tabs[i].flags&=~D_SELECTED;
7119 }
7120
7121 init_tabs[3].flags=D_SELECTED;
7122 return onCheatConsole();
7123 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7124 for(int32_t i=1; i<=8; i++)
7125 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7126
7127 if(zc_popup_dialog (triforce_dlg,-1)==9)
7128 {
7129 for(int32_t i=1; i<=8; i++)
7130 {
7131 game->lvlitems[i] &= ~liTRIFORCE;
7132 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7133 }
7134 }
7135 return D_O_K;*/
7136 }
7137
7138 bool rc = false;
7139 /*
7140 int32_t onEquipment()
7141 {
7142 for (int32_t i=0; i<MAXINITTABS; ++i)
7143 {
7144 init_tabs[i].flags&=~D_SELECTED;
7145 }
7146 init_tabs[0].flags=D_SELECTED;
7147 return onCheatConsole();
7148 }
7149 */
7150
7151 int32_t onItems()
7152 {
7153 for(int32_t i=0; i<MAXINITTABS; ++i)
7154 {
7155 init_tabs[i].flags&=~D_SELECTED;
7156 }
7157
7158 init_tabs[1].flags=D_SELECTED;
7159 return onCheatConsole();
7160 }
7161
7162 static DIALOG getnum_dlg[] =
7163 {
7164 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7165 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7166 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7167 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7168 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7169 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7170 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7171 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7172 };
7173
7174 int32_t getnumber(const char *prompt,int32_t initialval)
7175 {
7176 char buf[20];
7177 sprintf(buf,"%d",initialval);
7178 getnum_dlg[0].dp=(void *)prompt;
7179 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7180 getnum_dlg[2].dp=buf;
7181
7182 large_dialog(getnum_dlg);
7183
7184 if(zc_popup_dialog(getnum_dlg,2)==3)
7185 return atoi(buf);
7186
7187 return initialval;
7188 }
7189
7190 int32_t onLife()
7191 {
7192 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7193 cheats_enqueue(Cheat::Life, value);
7194 return D_O_K;
7195 }
7196
7197 int32_t onHeartC()
7198 {
7199 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7200 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7201 cheats_enqueue(Cheat::MaxLife, max_life);
7202 cheats_enqueue(Cheat::Life, life);
7203 return D_O_K;
7204 }
7205
7206 int32_t onMagicC()
7207 {
7208 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7209 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7210 cheats_enqueue(Cheat::MaxMagic, max_magic);
7211 cheats_enqueue(Cheat::Magic, magic);
7212 return D_O_K;
7213 }
7214
7215 int32_t onRupies()
7216 {
7217 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7218 cheats_enqueue(Cheat::Rupies, value);
7219 return D_O_K;
7220 }
7221
7222 int32_t onMaxBombs()
7223 {
7224 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7225 cheats_enqueue(Cheat::MaxBombs, value);
7226 cheats_enqueue(Cheat::Bombs, value);
7227 return D_O_K;
7228 }
7229
7230 int32_t onRefillLife()
7231 {
7232 cheats_enqueue(Cheat::Life, game->get_maxlife());
7233 return D_O_K;
7234 }
7235 int32_t onRefillMagic()
7236 {
7237 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7238 return D_O_K;
7239 }
7240 int32_t onClock()
7241 {
7242 cheats_enqueue(Cheat::Clock);
7243 return D_O_K;
7244 }
7245
7246 int32_t onQstPath()
7247 {
7248 char path[2048];
7249
7250 chop_path(qstdir);
7251 strcpy(path,qstdir);
7252
7253 go();
7254
7255 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7256 {
7257 chop_path(path);
7258 fix_filename_case(path);
7259 fix_filename_slashes(path);
7260 strcpy(qstdir,path);
7261 strcpy(qstpath,qstdir);
7262 }
7263
7264 comeback();
7265 return D_O_K;
7266 }
7267
7268 #include "dialog/cheat_dialog.h"
7269 int32_t onCheat()
7270 {
7271 call_setcheat_dialog();
7272 game->set_cheat(maxcheat);
7273 if(cheat) game->did_cheat(true);
7274 return D_O_K;
7275 }
7276
7277 int32_t onCheatRupies()
7278 {
7279 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7280 return D_O_K;
7281 }
7282
7283 int32_t onCheatArrows()
7284 {
7285 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7286 return D_O_K;
7287 }
7288
7289 int32_t onCheatBombs()
7290 {
7291 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7292 return D_O_K;
7293 }
7294
7295 // *** screen saver
7296
7297 9284885 int32_t after_time()
7298 {
7299
1/2
✓ Branch 0 taken 9284885 times.
✗ Branch 1 not taken.
9284885 if(ss_enable == 0)
7300 return INT_MAX;
7301
7302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284885 times.
9284885 if(ss_after <= 0)
7303 return 5 * 60;
7304
7305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284885 times.
9284885 if(ss_after <= 3)
7306 return ss_after * 15 * 60;
7307
7308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284885 times.
9284885 if(ss_after <= 13)
7309 return (ss_after - 3) * 60 * 60;
7310
7311 9284885 return MAX_IDLE + 1;
7312 9284885 }
7313
7314 static const char *after_str[15] =
7315 {
7316 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7317 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7318 "Never"
7319 };
7320
7321 const char *after_list(int32_t index, int32_t *list_size)
7322 {
7323 if(index < 0)
7324 {
7325 *list_size = 15;
7326 return NULL;
7327 }
7328
7329 return after_str[index];
7330 }
7331
7332 45 static ListData after__list(after_list, &font);
7333
7334 static DIALOG scrsaver_dlg[] =
7335 {
7336 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7337 45 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7338 45 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7339 45 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7340 45 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7341 45 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7342 45 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7343 45 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7344 45 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7345 45 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7346 45 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7347 45 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7348 45 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7349 45 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7350 };
7351
7352 int32_t onScreenSaver()
7353 {
7354 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7355 int32_t oldcfgs[3];
7356 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7357 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7358 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7359
7360 large_dialog(scrsaver_dlg);
7361
7362 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7363
7364 if(ret == 8 || ret == 9)
7365 {
7366 ss_after = scrsaver_dlg[5].d1;
7367 ss_speed = scrsaver_dlg[6].d2;
7368 ss_density = scrsaver_dlg[7].d2;
7369 if(oldcfgs[0] != ss_after)
7370 zc_set_config(cfg_sect,"ss_after",ss_after);
7371 if(oldcfgs[1] != ss_speed)
7372 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7373 if(oldcfgs[2] != ss_density)
7374 zc_set_config(cfg_sect,"ss_density",ss_density);
7375 }
7376
7377 if(ret == 9)
7378 // preview Screen Saver
7379 {
7380 clear_keybuf();
7381 Matrix(ss_speed, ss_density, 30);
7382 system_pal(true);
7383 sys_mouse();
7384 }
7385
7386 return D_O_K;
7387 }
7388
7389 /***** Menus *****/
7390
7391 static MENU game_menu[] =
7392 {
7393 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7394 { (char *)"", NULL, NULL, 0, NULL },
7395 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7396 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7397 { (char *)"", NULL, NULL, 0, NULL },
7398 #ifdef __EMSCRIPTEN__
7399 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7400 #elif defined(ALLEGRO_MACOSX)
7401 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7402 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7403 #else
7404 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7405 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7406 #endif
7407 { NULL, NULL, NULL, 0, NULL }
7408 };
7409
7410 static MENU title_menu[] =
7411 {
7412 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7413 { (char *)"&ZQuest Classic", onTitle_DX, NULL, 0, NULL },
7414 { (char *)"ZQuest Classic &2.50", onTitle_25, NULL, 0, NULL },
7415 { NULL, NULL, NULL, 0, NULL }
7416 };
7417
7418 static MENU snapshot_format_menu[] =
7419 {
7420 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7421 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7422 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7423 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7424 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7425 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7426 { NULL, NULL, NULL, 0, NULL }
7427 };
7428
7429 static MENU controls_menu[] =
7430 {
7431 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7432 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7433 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7434 { NULL, NULL, NULL, 0, NULL }
7435 };
7436
7437 static MENU name_entry_mode_menu[] =
7438 {
7439 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7440 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7441 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7442 { NULL, NULL, NULL, 0, NULL }
7443 };
7444
7445 static void set_controls_menu_active()
7446 {
7447
7448 }
7449
7450 static MENU window_menu[] =
7451 {
7452 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7453 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7454 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7455 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7456 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7457 { NULL, NULL, NULL, 0, NULL }
7458 };
7459 static MENU options_menu[] =
7460 {
7461 { "&Title Screen", NULL, title_menu, 0, NULL },
7462 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7463 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7464 { "&Window Settings", NULL, window_menu, 0, NULL },
7465 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7466 { "Pause In Background", onPauseInBackground, NULL, 0, NULL },
7467 { NULL, NULL, NULL, 0, NULL }
7468 };
7469 static MENU settings_menu[] =
7470 {
7471 { "&Sound...", onSound, NULL, 0, NULL },
7472 { "C&ontrols", NULL, controls_menu, 0, NULL },
7473 { "", NULL, NULL, 0, NULL },
7474 { "Options", NULL, options_menu, 0, NULL },
7475 { "", NULL, NULL, 0, NULL },
7476 //
7477 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7478 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7479 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7480 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7481 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7482 //
7483 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7484 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7485 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7486 { "", NULL, NULL, 0, NULL },
7487 { "Debu&g", onDebug, NULL, 0, NULL },
7488 //
7489 { NULL, NULL, NULL, 0, NULL }
7490 };
7491
7492
7493 static MENU misc_menu[] =
7494 {
7495 { (char *)"&About...", onAbout, NULL, 0, NULL },
7496 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7497 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7498 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7499 { (char *)"", NULL, NULL, 0, NULL },
7500 //5
7501 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7502 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7503 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7504 { (char *)"", NULL, NULL, 0, NULL },
7505 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7506 //10
7507 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7508 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7509 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7510 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7511 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7512 //15
7513 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7514 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7515 { NULL, NULL, NULL, 0, NULL }
7516 };
7517
7518 static MENU refill_menu[] =
7519 {
7520 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7521 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7522 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7523 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7524 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7525 { NULL, NULL, NULL, 0, NULL }
7526 };
7527
7528 static MENU show_menu[] =
7529 {
7530 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7531 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7532 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7533 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7534 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7535 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7536 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7537 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7538 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7539 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7540 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7541 { (char *)"", NULL, NULL, 0, NULL },
7542 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7543 { (char *)"", NULL, NULL, 0, NULL },
7544 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7545 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7546 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7547 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7548 { NULL, NULL, NULL, 0, NULL }
7549 };
7550
7551 static MENU cheat_menu[] =
7552 {
7553 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7554 { (char *)"", NULL, NULL, 0, NULL },
7555 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7556 { (char *)"", NULL, NULL, 0, NULL },
7557 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7558 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7559 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7560 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7561 { (char *)"", NULL, NULL, 0, NULL },
7562 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7563 { (char *)"", NULL, NULL, 0, NULL },
7564 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7565 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7566 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7567 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7568 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7569 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7570 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7571 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7572 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7573 { NULL, NULL, NULL, 0, NULL }
7574 };
7575
7576 #if DEVLEVEL > 0
7577 int32_t devLogging();
7578 int32_t devDebug();
7579 int32_t devTimestmp();
7580 #if DEVLEVEL > 1
7581 int32_t setCheat();
7582 #endif //DEVLEVEL > 1
7583 enum
7584 {
7585 dv_log,
7586 // dv_dbg,
7587 dv_tmpstmp,
7588 #if DEVLEVEL > 1
7589 dv_nil,
7590 dv_setcheat,
7591 #endif //DEVLEVEL > 1
7592 dv_max
7593 };
7594 static MENU dev_menu[] =
7595 {
7596 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7597 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7598 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7599 #if DEVLEVEL > 1
7600 { (char *)"", NULL, NULL, 0, NULL },
7601 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7602 #endif //DEVLEVEL > 1
7603 { NULL, NULL, NULL, 0, NULL }
7604 };
7605 int32_t devLogging()
7606 {
7607 dev_logging = !dev_logging;
7608 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7609 return D_O_K;
7610 }
7611 // int32_t devDebug()
7612 // {
7613 // dev_debug = !dev_debug;
7614 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7615 // return D_O_K;
7616 // }
7617 int32_t devTimestmp()
7618 {
7619 dev_timestmp = !dev_timestmp;
7620 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7621 return D_O_K;
7622 }
7623 #if DEVLEVEL > 1
7624 int32_t setCheat()
7625 {
7626 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7627 return D_O_K;
7628 }
7629 #endif //DEVLEVEL > 1
7630 #endif //DEVLEVEL > 0
7631
7632 MENU the_player_menu[] =
7633 {
7634 { (char *)"&Game", NULL, game_menu, 0, NULL },
7635 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7636 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7637 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7638 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7639 #if DEVLEVEL > 0
7640 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7641 #endif
7642 { NULL, NULL, NULL, 0, NULL }
7643 };
7644 int32_t onPauseInBackground()
7645 {
7646 if(jwin_alert3(
7647 "Toggle Pause In Background",
7648 "This action will change whether ZC Player pauses when the window loses focus.",
7649 "",
7650 "Proceed?",
7651 "&Yes",
7652 "&No",
7653 NULL,
7654 'y',
7655 'n',
7656 0,
7657 get_zc_font(font_lfont)) == 1)
7658 {
7659 pause_in_background = pause_in_background ? 0 : 1;
7660 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7661 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7662 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7663 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7664 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7665 }
7666 options_menu[5].flags =(pause_in_background)?D_SELECTED:0;
7667 return D_O_K;
7668 }
7669
7670 int32_t onKeyboardEntry()
7671 {
7672 NameEntryMode=0;
7673 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7674 return D_O_K;
7675 }
7676
7677 int32_t onLetterGridEntry()
7678 {
7679 NameEntryMode=1;
7680 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7681 return D_O_K;
7682 }
7683
7684 int32_t onExtLetterGridEntry()
7685 {
7686 NameEntryMode=2;
7687 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7688 return D_O_K;
7689 }
7690
7691 static BITMAP* oldscreen;
7692 int32_t onFullscreenMenu()
7693 {
7694 // super hacks
7695 screen = oldscreen;
7696 if (onFullscreen() == D_REDRAW)
7697 {
7698 oldscreen = screen;
7699 }
7700 screen = menu_bmp;
7701 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7702 return D_O_K;
7703 }
7704
7705 45 void fix_menu()
7706 {
7707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(!debug_enabled)
7708 45 settings_menu[13].text = NULL;
7709 45 }
7710
7711 static DIALOG system_dlg[] =
7712 {
7713 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7714 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7715 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7716 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7717 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7718 #ifndef ALLEGRO_MACOSX
7719 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7720 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7721 #else
7722 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7723 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7724 #endif
7725 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7726 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7727 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7728 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7729 };
7730
7731 void reset_snapshot_format_menu()
7732 {
7733 for(int32_t i=0; i<ssfmtMAX; ++i)
7734 {
7735 snapshot_format_menu[i].flags=0;
7736 }
7737 }
7738
7739 int32_t onSetSnapshotFormat()
7740 {
7741 switch(active_menu->text[1])
7742 {
7743 case 'B': //"&BMP"
7744 SnapshotFormat=0;
7745 break;
7746
7747 case 'G': //"&GIF"
7748 SnapshotFormat=1;
7749 break;
7750
7751 case 'J': //"&JPG"
7752 SnapshotFormat=2;
7753 break;
7754
7755 case 'P': //"&PNG"
7756 SnapshotFormat=3;
7757 break;
7758
7759 case 'C': //"PC&X"
7760 SnapshotFormat=4;
7761 break;
7762
7763 case 'T': //"&TGA"
7764 SnapshotFormat=5;
7765 break;
7766
7767 case 'L': //"&LBM"
7768 SnapshotFormat=6;
7769 break;
7770 }
7771 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7772
7773 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7774 return D_O_K;
7775 }
7776
7777
7778 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7779 {
7780 PALETTE tmp;
7781
7782 for(int32_t i=0; i<256; i++)
7783 {
7784 tmp[i].r=r;
7785 tmp[i].g=g;
7786 tmp[i].b=b;
7787 }
7788
7789 fade_interpolate(src,tmp,dest,pos,from,to);
7790 }
7791
7792 13 void system_pal(bool force)
7793 {
7794
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if(is_sys_pal && !force) return;
7795 13 is_sys_pal = true;
7796 13 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7797 13 hw_palette = &syspal;
7798 13 update_hw_pal = true;
7799 13 }
7800
7801 static uint32_t entered_sys_pal = 0;
7802 13 void enter_sys_pal()
7803 {
7804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(is_sys_pal)
7805 {
7806 if(entered_sys_pal)
7807 ++entered_sys_pal;
7808 return;
7809 }
7810 13 sys_mouse();
7811 13 system_pal(true);
7812 13 ++entered_sys_pal;
7813 13 }
7814 13 void exit_sys_pal()
7815 {
7816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(entered_sys_pal)
7817 {
7818
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!--entered_sys_pal)
7819 {
7820 13 game_pal();
7821 13 game_mouse();
7822 13 }
7823 13 }
7824 13 }
7825
7826 void switch_out_callback()
7827 {
7828 if (pause_in_background && !MenuOpen)
7829 {
7830 System();
7831 }
7832 }
7833
7834 void switch_in_callback()
7835 {
7836 }
7837
7838 420 void game_pal()
7839 {
7840 420 is_sys_pal = false;
7841 420 entered_sys_pal = 0;
7842 420 hw_palette = &RAMpal;
7843 420 update_hw_pal = true;
7844 420 }
7845
7846 static char bar_str[] = "";
7847
7848 13 void music_pause()
7849 {
7850 //al_pause_duh(tmplayer);
7851 13 zcmusic_pause(zcmusic, ZCM_PAUSE);
7852 13 zc_midi_pause();
7853 13 }
7854
7855 void music_resume()
7856 {
7857 //al_resume_duh(tmplayer);
7858 zcmusic_pause(zcmusic, ZCM_RESUME);
7859 zc_midi_resume();
7860 }
7861
7862 3357 void music_stop()
7863 {
7864 //al_stop_duh(tmplayer);
7865 //unload_duh(tmusic);
7866 //tmusic=NULL;
7867 //tmplayer=NULL;
7868 3357 zcmusic_stop(zcmusic);
7869 3357 zcmusic_unload_file(zcmusic);
7870 3357 zc_stop_midi();
7871 3357 currmidi=-1;
7872 3357 }
7873
7874 void System()
7875 {
7876 mouse_down=gui_mouse_b();
7877 music_pause();
7878 pause_all_sfx();
7879 MenuOpen = true;
7880 enter_sys_pal();
7881 // FONT *oldfont=font;
7882 // font=tfont;
7883
7884 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7885 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7886
7887 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7888 #if DEVLEVEL > 1
7889 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7890 #endif
7891 game_menu[3].flags =
7892 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7893 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7894 clear_keybuf();
7895
7896 DIALOG_PLAYER *p;
7897
7898 clear_bitmap(menu_bmp);
7899 oldscreen = screen;
7900 screen = menu_bmp;
7901
7902 p = init_dialog(system_dlg,-1);
7903
7904 // drop the menu on startup if menu button pressed
7905 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7906 simulate_keypress(KEY_G << 8);
7907
7908 do
7909 {
7910 if(close_button_quit)
7911 {
7912 close_button_quit = false;
7913 f_Quit(qEXIT);
7914 if(Quit) break;
7915 }
7916 rest(17);
7917
7918 if(mouse_down && !gui_mouse_b())
7919 mouse_down=0;
7920
7921 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
7922 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
7923 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
7924
7925 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
7926 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
7927 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
7928 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
7929 settings_menu[9].flags = TransLayers?D_SELECTED:0;
7930 settings_menu[10].flags = NESquit?D_SELECTED:0;
7931 settings_menu[11].flags = volkeys?D_SELECTED:0;
7932
7933 window_menu[0].flags = DragAspect?D_SELECTED:0;
7934 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
7935 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
7936 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
7937 window_menu[4].flags = stretchGame?D_SELECTED:0;
7938
7939 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
7940 options_menu[5].flags = (pause_in_background)?D_SELECTED:0;
7941
7942 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
7943 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
7944 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
7945
7946 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
7947 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
7948 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
7949
7950 bool nocheat = (replay_is_replaying() || !Playing
7951 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7952 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
7953 cheat_menu[0].flags = 0;
7954 refill_menu[4].flags = get_qr(qr_TRUEARROWS) ? 0 : D_DISABLED;
7955 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
7956 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
7957 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
7958 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
7959 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
7960 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
7961 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
7962 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
7963
7964 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
7965 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
7966 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
7967 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
7968 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
7969 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
7970 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
7971 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
7972 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
7973 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
7974 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
7975 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
7976 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
7977 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
7978 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
7979
7980 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
7981 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
7982
7983 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
7984 (char *)"Disable recording new saves" :
7985 (char *)"Enable recording new saves";
7986 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
7987 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
7988 (char *)"Stop recording" :
7989 (char *)"Stop replaying";
7990 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
7991 replay_menu[6].text = replay_is_snapshot_all_frames() ?
7992 (char *)"Disable snapshot all frames" :
7993 (char *)"Enable snapshot all frames";
7994
7995 reset_snapshot_format_menu();
7996 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
7997
7998 if(debug_enabled)
7999 {
8000 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8001 }
8002
8003 if(gui_mouse_b() && !mouse_down)
8004 break;
8005
8006 // press menu to drop the menu
8007 if(rMbtn())
8008 simulate_keypress(KEY_G << 8);
8009
8010 if(input_idle(true) > after_time())
8011 // run Screeen Saver
8012 {
8013 // Screen saver enabled for now.
8014 clear_keybuf();
8015 Matrix(ss_speed, ss_density, 0);
8016 system_pal(true);
8017 sys_mouse();
8018 broadcast_dialog_message(MSG_DRAW, 0);
8019 }
8020
8021 update_hw_screen();
8022 }
8023 while(update_dialog(p));
8024
8025 screen = oldscreen;
8026
8027 // font=oldfont;
8028 mouse_down=gui_mouse_b();
8029 shutdown_dialog(p);
8030 MenuOpen = false;
8031 if(Quit)
8032 {
8033 kill_sfx();
8034 music_stop();
8035 update_hw_screen();
8036 }
8037 else
8038 {
8039 music_resume();
8040 resume_all_sfx();
8041
8042 if(rc)
8043 ringcolor(false);
8044 }
8045 exit_sys_pal();
8046
8047 eat_buttons();
8048
8049 rc=false;
8050 clear_keybuf();
8051 // text_mode(0);
8052 }
8053
8054 45 void fix_dialogs()
8055 {
8056 45 jwin_center_dialog(about_dlg);
8057 45 jwin_center_dialog(gamepad_dlg);
8058 45 jwin_center_dialog(credits_dlg);
8059 45 jwin_center_dialog(gamemode_dlg);
8060 45 jwin_center_dialog(getnum_dlg);
8061 45 jwin_center_dialog(goto_dlg);
8062 45 jwin_center_dialog(keyboard_control_dlg);
8063 45 jwin_center_dialog(midi_dlg);
8064 45 jwin_center_dialog(quest_dlg);
8065 45 jwin_center_dialog(scrsaver_dlg);
8066 45 jwin_center_dialog(sound_dlg);
8067 45 jwin_center_dialog(triforce_dlg);
8068
8069 // digi_dp[1] += scrx;
8070 // digi_dp[2] += scry;
8071 // midi_dp[1] += scrx;
8072 // midi_dp[2] += scry;
8073 // pan_dp[1] += scrx;
8074 // pan_dp[2] += scry;
8075 // emus_dp[1] += scrx;
8076 // emus_dp[2] += scry;
8077 // buf_dp[1] += scrx;
8078 // buf_dp[2] += scry;
8079 // sfx_dp[1] += scrx;
8080 // sfx_dp[2] += scry;
8081 45 }
8082
8083 /*****************************/
8084 /**** Custom Sound System ****/
8085 /*****************************/
8086
8087 45 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8088 {
8089
2/4
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
45 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8090 }
8091
8092 // Run an NSF, or a MIDI if the NSF is missing somehow.
8093 149 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8094 {
8095 149 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8096
8097 // Found it
8098
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 79 times.
149 if(newzcmusic!=NULL)
8099 {
8100 70 zcmusic_stop(zcmusic);
8101 70 zcmusic_unload_file(zcmusic);
8102 70 zc_stop_midi();
8103
8104 70 zcmusic=newzcmusic;
8105 70 zcmusic_play(zcmusic, emusic_volume);
8106
8107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(track>0)
8108 70 zcmusic_change_track(zcmusic,track);
8109
8110 70 return true;
8111 }
8112
8113 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8114
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 else if(midi>-1000)
8115 jukebox(midi);
8116
8117 79 return false;
8118 149 }
8119
8120 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8121 {
8122 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8123 // Found it
8124 if(newzcmusic!=NULL)
8125 {
8126 zcmusic_stop(zcmusic);
8127 zcmusic_unload_file(zcmusic);
8128 zc_stop_midi();
8129
8130 zcmusic=newzcmusic;
8131 zcmusic_play(zcmusic, emusic_volume);
8132
8133 if(track>0)
8134 zcmusic_change_track(zcmusic,track);
8135
8136 return true;
8137 }
8138
8139 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8140 else if(midi>-1000)
8141 jukebox(midi);
8142
8143 return false;
8144 }
8145
8146 int32_t get_zcmusicpos()
8147 {
8148 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8149 return debugtracething;
8150 return 0;
8151 }
8152
8153 void set_zcmusicpos(int32_t position)
8154 {
8155 zcmusic_set_curpos(zcmusic, position);
8156 }
8157
8158 void set_zcmusicspeed(int32_t speed)
8159 {
8160 int32_t newspeed = vbound(speed, 0, 10000);
8161 zcmusic_set_speed(zcmusic, newspeed);
8162 }
8163
8164 63871 void jukebox(int32_t index,int32_t loop)
8165 {
8166
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if (is_headless())
8167 63871 return;
8168
8169 music_stop();
8170
8171 if(index<0) index=MAXMIDIS-1;
8172
8173 if(index>=MAXMIDIS) index=0;
8174
8175 music_stop();
8176
8177 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8178 // stuck notes when a song stops. This fixes it.
8179 if(strcmp(midi_driver->name, "DIGMID")==0)
8180 zc_set_volume(0, 0);
8181
8182 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8183 zc_play_midi((MIDI*)tunes[index].data,loop);
8184
8185 if(tunes[index].start>0)
8186 zc_midi_seek(tunes[index].start);
8187
8188 midi_loop_start = tunes[index].loop_start;
8189 midi_loop_end = tunes[index].loop_end;
8190
8191 currmidi=index;
8192 master_volume(digi_volume,midi_volume);
8193 63871 }
8194
8195 63871 void jukebox(int32_t index)
8196 {
8197
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if(index<0) index=MAXMIDIS-1;
8198
8199
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if(index>=MAXMIDIS) index=0;
8200
8201 // do nothing if it's already playing
8202
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63871 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63871 if(index==currmidi && midi_pos>=0)
8203 {
8204 return;
8205 }
8206
8207 63871 jukebox(index,tunes[index].loop);
8208 63871 }
8209
8210 16 void play_DmapMusic()
8211 {
8212
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (is_headless())
8213 16 return;
8214
8215 static char tfile[2048];
8216 static int32_t ttrack=0;
8217 bool domidi=false;
8218
8219 if(DMaps[currdmap].tmusic[0]!=0)
8220 {
8221 if(zcmusic==NULL ||
8222 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8223 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8224 {
8225 if(zcmusic != NULL)
8226 {
8227 zcmusic_stop(zcmusic);
8228 zcmusic_unload_file(zcmusic);
8229 zcmusic = NULL;
8230 }
8231
8232 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8233
8234 if(zcmusic!=NULL)
8235 {
8236 zc_stop_midi();
8237 strcpy(tfile,DMaps[currdmap].tmusic);
8238 zcmusic_play(zcmusic, emusic_volume);
8239 int32_t temptracks=0;
8240 temptracks=zcmusic_get_tracks(zcmusic);
8241 temptracks=(temptracks<2)?1:temptracks;
8242 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8243 zcmusic_change_track(zcmusic,ttrack);
8244 }
8245 else
8246 {
8247 tfile[0] = 0;
8248 domidi=true;
8249 }
8250 }
8251 }
8252 else
8253 {
8254 domidi=true;
8255 }
8256
8257 if(domidi)
8258 {
8259 int32_t m=DMaps[currdmap].midi;
8260
8261 switch(m)
8262 {
8263 case 1:
8264 jukebox(ZC_MIDI_OVERWORLD);
8265 break;
8266
8267 case 2:
8268 jukebox(ZC_MIDI_DUNGEON);
8269 break;
8270
8271 case 3:
8272 jukebox(ZC_MIDI_LEVEL9);
8273 break;
8274
8275 default:
8276 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8277 jukebox(m+MIDIOFFSET_DMAP);
8278 else
8279 music_stop();
8280 }
8281 }
8282 16 }
8283
8284 15752 void playLevelMusic()
8285 {
8286
1/2
✓ Branch 0 taken 15752 times.
✗ Branch 1 not taken.
15752 if (is_headless())
8287 15752 return;
8288
8289 int32_t m=tmpscr->screen_midi;
8290
8291 switch(m)
8292 {
8293 case -2:
8294 music_stop();
8295 break;
8296
8297 case -1:
8298 play_DmapMusic();
8299 break;
8300
8301 case 1:
8302 jukebox(ZC_MIDI_OVERWORLD);
8303 break;
8304
8305 case 2:
8306 jukebox(ZC_MIDI_DUNGEON);
8307 break;
8308
8309 case 3:
8310 jukebox(ZC_MIDI_LEVEL9);
8311 break;
8312
8313 default:
8314 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8315 jukebox(m+MIDIOFFSET_MAPSCR);
8316 else
8317 music_stop();
8318 }
8319 15752 }
8320
8321 45 void master_volume(int32_t dv,int32_t mv)
8322 {
8323
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 45 times.
✗ Branch 7 not taken.
45 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8324
8325
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 45 times.
✗ Branch 7 not taken.
45 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8326
8327
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 45 times.
45 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8328 45 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8329 45 }
8330
8331 /*****************/
8332 /***** SFX *****/
8333 /*****************/
8334
8335 // array of voices, one for each sfx sample in the data file
8336 // 0+ = voice #
8337 // -1 = voice not allocated
8338 45 void Z_init_sound()
8339 {
8340
2/2
✓ Branch 0 taken 11520 times.
✓ Branch 1 taken 45 times.
11565 for(int32_t i=0; i<WAV_COUNT; i++)
8341 11520 sfx_voice[i]=-1;
8342
8343
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 45 times.
360 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8344 315 tunes[i].data = (MIDI*)mididata[i].dat;
8345
8346
2/2
✓ Branch 0 taken 11340 times.
✓ Branch 1 taken 45 times.
11385 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8347 11340 tunes[ZC_MIDI_COUNT+j].data=NULL;
8348
8349 45 master_volume(digi_volume,midi_volume);
8350 45 }
8351
8352 // returns number of voices currently allocated
8353 int32_t sfx_count()
8354 {
8355 int32_t c=0;
8356
8357 for(int32_t i=0; i<WAV_COUNT; i++)
8358 if(sfx_voice[i]!=-1)
8359 ++c;
8360
8361 return c;
8362 }
8363
8364 // clean up finished samples
8365 9216141 void sfx_cleanup()
8366 {
8367
2/2
✓ Branch 0 taken 2359332096 times.
✓ Branch 1 taken 9216141 times.
2368548237 for(int32_t i=0; i<WAV_COUNT; i++)
8368
3/4
✓ Branch 0 taken 619254 times.
✓ Branch 1 taken 2358712842 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 619254 times.
2359951350 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8369 {
8370 619254 deallocate_voice(sfx_voice[i]);
8371 619254 sfx_voice[i]=-1;
8372 619254 }
8373 9216141 }
8374
8375 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8376 // if a voice is already allocated (and/or playing), then it just returns true
8377 // Returns true: voice is allocated
8378 // false: unsuccessful
8379 963608 bool sfx_init(int32_t index)
8380 {
8381 // check index
8382
3/4
✓ Branch 0 taken 721282 times.
✓ Branch 1 taken 242326 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721282 times.
963608 if(index<=0 || index>=WAV_COUNT)
8383 242326 return false;
8384
8385
2/2
✓ Branch 0 taken 102011 times.
✓ Branch 1 taken 619271 times.
721282 if(sfx_voice[index]==-1)
8386 {
8387
2/2
✓ Branch 0 taken 209876 times.
✓ Branch 1 taken 409395 times.
619271 if(sfxdat)
8388 {
8389
1/2
✓ Branch 0 taken 209876 times.
✗ Branch 1 not taken.
209876 if(index<Z35)
8390 {
8391 209876 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8392 209876 }
8393 else
8394 {
8395 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8396 }
8397 209876 }
8398 else
8399 {
8400 409395 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8401 }
8402
8403 619271 voice_set_volume(sfx_voice[index], sfx_volume);
8404 619271 }
8405
8406 721282 return sfx_voice[index] != -1;
8407 963608 }
8408
8409 // plays an sfx sample
8410 963608 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8411 {
8412
2/2
✓ Branch 0 taken 721282 times.
✓ Branch 1 taken 242326 times.
963608 if(!sfx_init(index))
8413 242326 return;
8414
8415
1/2
✓ Branch 0 taken 721282 times.
✗ Branch 1 not taken.
721282 if (!is_headless())
8416 {
8417 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8418 voice_set_pan(sfx_voice[index],pan);
8419
8420 int32_t pos = voice_get_position(sfx_voice[index]);
8421
8422 if(restart) voice_set_position(sfx_voice[index],0);
8423
8424 if(pos<=0)
8425 voice_start(sfx_voice[index]);
8426 }
8427
8428
3/4
✓ Branch 0 taken 398006 times.
✓ Branch 1 taken 323276 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398006 times.
721282 if (restart && replay_is_debug())
8429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398006 times.
398006 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8430 963608 }
8431
8432 // true if sfx is allocated
8433 67537 bool sfx_allocated(int32_t index)
8434 {
8435
3/4
✓ Branch 0 taken 9408 times.
✓ Branch 1 taken 58129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9408 times.
67537 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8436 }
8437
8438 // start it (in loop mode) if it's not already playing,
8439 // otherwise adjust it to play in loop mode -DD
8440 178462 void cont_sfx(int32_t index)
8441 {
8442
1/2
✓ Branch 0 taken 178462 times.
✗ Branch 1 not taken.
178462 if (is_headless())
8443 178462 return;
8444
8445 if(!sfx_init(index))
8446 {
8447 return;
8448 }
8449
8450 if(voice_get_position(sfx_voice[index])<=0)
8451 {
8452 voice_set_position(sfx_voice[index],0);
8453 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8454 voice_start(sfx_voice[index]);
8455 }
8456 else
8457 {
8458 adjust_sfx(index, 128, true);
8459 }
8460 178462 }
8461
8462 // adjust parameters while playing
8463 4075 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8464 {
8465
4/6
✓ Branch 0 taken 2315 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2315 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2315 times.
4075 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8466 4075 return;
8467
8468 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8469 voice_set_pan(sfx_voice[index],pan);
8470 4075 }
8471
8472 // pauses a voice
8473 1725 void pause_sfx(int32_t index)
8474 {
8475
3/6
✓ Branch 0 taken 1725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1725 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1725 times.
1725 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8476 voice_stop(sfx_voice[index]);
8477 1725 }
8478
8479 // resumes a voice
8480 747 void resume_sfx(int32_t index)
8481 {
8482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 if (is_headless())
8483 747 return;
8484
8485 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8486 voice_start(sfx_voice[index]);
8487 747 }
8488
8489 // pauses all active voices
8490 451 void pause_all_sfx()
8491 {
8492
2/2
✓ Branch 0 taken 115456 times.
✓ Branch 1 taken 451 times.
115907 for(int32_t i=0; i<WAV_COUNT; i++)
8493
2/2
✓ Branch 0 taken 115455 times.
✓ Branch 1 taken 1 times.
115457 if(sfx_voice[i]!=-1)
8494 1 voice_stop(sfx_voice[i]);
8495 451 }
8496
8497 // resumes all paused voices
8498 438 void resume_all_sfx()
8499 {
8500
2/2
✓ Branch 0 taken 112128 times.
✓ Branch 1 taken 438 times.
112566 for(int32_t i=0; i<WAV_COUNT; i++)
8501
1/2
✓ Branch 0 taken 112128 times.
✗ Branch 1 not taken.
112128 if(sfx_voice[i]!=-1)
8502 voice_start(sfx_voice[i]);
8503 438 }
8504
8505 // stops an sfx and deallocates the voice
8506 7318083 void stop_sfx(int32_t index)
8507 {
8508
3/4
✓ Branch 0 taken 6167429 times.
✓ Branch 1 taken 1150654 times.
✓ Branch 2 taken 6167429 times.
✗ Branch 3 not taken.
7318083 if(index<=0 || index>=WAV_COUNT)
8509 1150654 return;
8510
8511
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 6167418 times.
6167429 if(sfx_voice[index]!=-1)
8512 {
8513 11 deallocate_voice(sfx_voice[index]);
8514 11 sfx_voice[index]=-1;
8515 11 }
8516 7318083 }
8517
8518 // Stops SFX played by Hero's item of the given family
8519 128638 void stop_item_sfx(int32_t family)
8520 {
8521 128638 int32_t id=current_item_id(family);
8522
8523
2/2
✓ Branch 0 taken 128083 times.
✓ Branch 1 taken 555 times.
128638 if(id<0)
8524 128083 return;
8525
8526 555 stop_sfx(itemsbuf[id].usesound);
8527 128638 }
8528
8529 3219 void kill_sfx()
8530 {
8531
2/2
✓ Branch 0 taken 824064 times.
✓ Branch 1 taken 3219 times.
827283 for(int32_t i=0; i<WAV_COUNT; i++)
8532
2/2
✓ Branch 0 taken 824058 times.
✓ Branch 1 taken 6 times.
824070 if(sfx_voice[i]!=-1)
8533 {
8534 6 deallocate_voice(sfx_voice[i]);
8535 6 sfx_voice[i]=-1;
8536 6 }
8537 3219 }
8538
8539 659813 int32_t pan(int32_t x)
8540 {
8541
1/4
✓ Branch 0 taken 659813 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
659813 switch(pan_style)
8542 {
8543 case 0:
8544 return 128;
8545
8546 case 1:
8547 659813 return vbound((x>>1)+68,0,255);
8548
8549 case 2:
8550 return vbound(((x*3)>>2)+36,0,255);
8551 }
8552
8553 return vbound(x,0,255);
8554 659813 }
8555
8556 /*******************************/
8557 /******* Input Handlers ********/
8558 /*******************************/
8559
8560 25088115 bool joybtn(int32_t b)
8561 {
8562
1/2
✓ Branch 0 taken 25088115 times.
✗ Branch 1 not taken.
25088115 if(b == 0)
8563 return false;
8564
1/2
✓ Branch 0 taken 25088115 times.
✗ Branch 1 not taken.
25088115 if (b-1 >= joy[joystick_index].num_buttons)
8565 25088115 return false;
8566
8567 return joy[joystick_index].button[b-1].b !=0;
8568 25088115 }
8569
8570 const char* joybtn_name(int32_t b)
8571 {
8572 if (b <= 0 || b > joy[joystick_index].num_buttons)
8573 return "";
8574
8575 return joy[joystick_index].button[b-1].name;
8576 }
8577
8578 int32_t next_press_key();
8579
8580 int32_t next_press_btn()
8581 {
8582 clear_keybuf();
8583 /*bool b[joy[joystick_index].num_buttons+1];
8584
8585 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8586 b[i]=joybtn(i);*/
8587
8588 //first, we need to wait until they're pressing no buttons
8589 for(;;)
8590 {
8591 if(keypressed())
8592 {
8593 switch(readkey()>>8)
8594 {
8595 case KEY_ESC:
8596 return -1;
8597
8598 case KEY_SPACE:
8599 return 0;
8600 }
8601 }
8602
8603 poll_joystick();
8604 bool done = true;
8605
8606 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8607 {
8608 if(joybtn(i)) done = false;
8609 }
8610
8611 if(done) break;
8612 rest(1);
8613 }
8614
8615 //now, we need to wait for them to press any button
8616 for(;;)
8617 {
8618 if(keypressed())
8619 {
8620 switch(readkey()>>8)
8621 {
8622 case KEY_ESC:
8623 return -1;
8624
8625 case KEY_SPACE:
8626 return 0;
8627 }
8628 }
8629
8630 poll_joystick();
8631
8632 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8633 {
8634 if(joybtn(i)) return i;
8635 }
8636 rest(1);
8637 }
8638 }
8639
8640 1198448 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8641 {
8642
2/2
✓ Branch 0 taken 1193968 times.
✓ Branch 1 taken 4480 times.
1198448 bool ret = btn && !flag;
8643 1198448 flag = rawbtn;
8644
8645 1198448 return ret;
8646 }
8647 190895598 static bool rButton(bool &btn, bool &flag)
8648 {
8649
2/2
✓ Branch 0 taken 184052365 times.
✓ Branch 1 taken 6843233 times.
190895598 bool ret = btn && !flag;
8650 190895598 flag = btn;
8651
8652 190895598 return ret;
8653 }
8654 1846969 static bool rButtonPeek(bool btn, bool flag)
8655 {
8656
2/2
✓ Branch 0 taken 1644296 times.
✓ Branch 1 taken 202673 times.
1846969 if(!btn)
8657 {
8658 1644296 return false;
8659 }
8660
2/2
✓ Branch 0 taken 17699 times.
✓ Branch 1 taken 184974 times.
202673 else if(!flag)
8661 {
8662 17699 return true;
8663 }
8664
8665 184974 return false;
8666 1846969 }
8667
8668 // Updated only by keyboard/gamepad.
8669 // If in replay mode, this is set directly by the replay system.
8670 // This should never be read from directly - use control_state instead.
8671 bool raw_control_state[ZC_CONTROL_STATES];
8672
8673 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8674 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8675 // lasts until the next call to load_control_state.
8676 bool control_state[ZC_CONTROL_STATES];
8677 bool disable_control[ZC_CONTROL_STATES];
8678 bool drunk_toggle_state[11];
8679 bool disabledKeys[127];
8680 bool KeyInput[127];
8681 bool KeyPress[127];
8682
8683 bool key_current_frame[127];
8684 bool key_previous_frame[127];
8685
8686 static bool key_system[127];
8687 static bool key_system_previous[127];
8688 static bool key_system_press[127];
8689
8690 bool button_press[ZC_CONTROL_STATES];
8691 bool button_hold[ZC_CONTROL_STATES];
8692
8693 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8694 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8695 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8696 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8697 #define STICK_PRECISION 56 //define your own sensitivity
8698
8699 7799048 void load_control_state()
8700 {
8701 7799048 load_control_called_this_frame = true;
8702
8703
2/2
✓ Branch 0 taken 4831538 times.
✓ Branch 1 taken 2967510 times.
7799048 if (replay_version_check(8, 11))
8704 {
8705
2/2
✓ Branch 0 taken 53415180 times.
✓ Branch 1 taken 2967510 times.
56382690 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8706 53415180 down_control_states[i] = raw_control_state[i];
8707 2967510 }
8708
8709
1/2
✓ Branch 0 taken 7799048 times.
✗ Branch 1 not taken.
7799048 if (!replay_is_replaying())
8710 {
8711 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8712 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8713 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8714 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8715 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8716 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8717 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8718 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8719 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8720 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8721 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8722 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8723 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8724 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8725
8726 if(num_joysticks != 0)
8727 {
8728 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8729 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8730 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8731 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8732 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8733 }
8734 else
8735 {
8736 raw_control_state[14] = false;
8737 raw_control_state[15] = false;
8738 raw_control_state[16] = false;
8739 raw_control_state[17] = false;
8740 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8741 }
8742 bool did_bad_cutscene_btn = false;
8743 for(int q = 0; q < 18; ++q)
8744 if(raw_control_state[q] && !active_cutscene.can_button(q))
8745 {
8746 raw_control_state[q] = false;
8747 did_bad_cutscene_btn = true;
8748 }
8749 if(did_bad_cutscene_btn)
8750 active_cutscene.error();
8751 }
8752
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7799045 times.
7799048 if (replay_is_active())
8753 {
8754
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 6783830 times.
7799045 if (replay_get_version() < 3)
8755 1015215 replay_poll();
8756
3/4
✓ Branch 0 taken 6783830 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5022455 times.
✓ Branch 3 taken 1761375 times.
6783830 else if (replay_is_replaying() && replay_get_version() < 6)
8757 1761375 replay_peek_input();
8758
3/4
✓ Branch 0 taken 5022455 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2054945 times.
✓ Branch 3 taken 2967510 times.
5022455 else if (replay_is_replaying() && replay_version_check(8, 11))
8759 2967510 replay_peek_input();
8760
2/2
✓ Branch 0 taken 6694758 times.
✓ Branch 1 taken 1104287 times.
7799045 if (replay_get_version() == 8)
8761 1104287 update_keys();
8762 7799045 }
8763
8764 // Some test replay files were made before a serious input bug was fixed, so instead
8765 // of re-doing them or tossing them out, just check for that zplay version.
8766
3/4
✓ Branch 0 taken 7799042 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 7677142 times.
7799048 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8767
2/2
✓ Branch 0 taken 7799042 times.
✓ Branch 1 taken 140382756 times.
148181798 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8768 {
8769 140382756 control_state[i] = raw_control_state[i];
8770
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 90895446 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
140382756 if (botched_input && !control_state[i])
8771 47077142 down_control_states[i] = false;
8772 140382756 }
8773
8774 7799042 button_press[0]=rButton(control_state[0],button_hold[0]);
8775 7799042 button_press[1]=rButton(control_state[1],button_hold[1]);
8776 7799042 button_press[2]=rButton(control_state[2],button_hold[2]);
8777 7799042 button_press[3]=rButton(control_state[3],button_hold[3]);
8778 7799042 button_press[4]=rButton(control_state[4],button_hold[4]);
8779 7799042 button_press[5]=rButton(control_state[5],button_hold[5]);
8780 7799042 button_press[6]=rButton(control_state[6],button_hold[6]);
8781 7799042 button_press[7]=rButton(control_state[7],button_hold[7]);
8782 7799042 button_press[8]=rButton(control_state[8],button_hold[8]);
8783 7799042 button_press[9]=rButton(control_state[9],button_hold[9]);
8784 7799042 button_press[10]=rButton(control_state[10],button_hold[10]);
8785 7799042 button_press[11]=rButton(control_state[11],button_hold[11]);
8786 7799042 button_press[12]=rButton(control_state[12],button_hold[12]);
8787 7799042 button_press[13]=rButton(control_state[13],button_hold[13]);
8788 7799042 button_press[14]=rButton(control_state[14],button_hold[14]);
8789 7799042 button_press[15]=rButton(control_state[15],button_hold[15]);
8790 7799042 button_press[16]=rButton(control_state[16],button_hold[16]);
8791 7799042 button_press[17]=rButton(control_state[17],button_hold[17]);
8792 7799042 }
8793
8794 // Returns true if any game key is pressed. This is needed because keypressed()
8795 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8796 40241593 bool zc_key_pressed()
8797 //may also need to use zc_getrawkey
8798 {
8799
7/10
✓ Branch 0 taken 32590677 times.
✓ Branch 1 taken 7650916 times.
✓ Branch 2 taken 7650916 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7650916 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6394847 times.
✓ Branch 7 taken 6394847 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2461199 times.
42702792 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8800
4/6
✓ Branch 0 taken 6394847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6394847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4843216 times.
✓ Branch 5 taken 4843216 times.
6394847 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8801
4/6
✓ Branch 0 taken 4843216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4843216 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3142597 times.
✓ Branch 5 taken 3142597 times.
4843216 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8802
4/6
✓ Branch 0 taken 3142597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3142597 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2731663 times.
✓ Branch 5 taken 2731663 times.
3142597 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8803
1/2
✓ Branch 0 taken 2731663 times.
✗ Branch 1 not taken.
2731663 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8804
3/4
✓ Branch 0 taken 2612256 times.
✓ Branch 1 taken 119407 times.
✓ Branch 2 taken 2612256 times.
✗ Branch 3 not taken.
2731663 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8805
3/4
✓ Branch 0 taken 2493362 times.
✓ Branch 1 taken 118894 times.
✓ Branch 2 taken 2493362 times.
✗ Branch 3 not taken.
2612256 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8806
3/4
✓ Branch 0 taken 2478217 times.
✓ Branch 1 taken 15145 times.
✓ Branch 2 taken 2478217 times.
✗ Branch 3 not taken.
2493362 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8807
3/4
✓ Branch 0 taken 2464718 times.
✓ Branch 1 taken 13499 times.
✓ Branch 2 taken 2464718 times.
✗ Branch 3 not taken.
2478217 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8808
3/4
✓ Branch 0 taken 2462224 times.
✓ Branch 1 taken 2494 times.
✓ Branch 2 taken 2462224 times.
✗ Branch 3 not taken.
2464718 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8809
3/4
✓ Branch 0 taken 2462034 times.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 2462034 times.
✗ Branch 3 not taken.
2462224 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8810
3/4
✓ Branch 0 taken 2461224 times.
✓ Branch 1 taken 810 times.
✓ Branch 2 taken 2461224 times.
✗ Branch 3 not taken.
2462034 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8811
3/4
✓ Branch 0 taken 2461218 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 2461218 times.
✗ Branch 3 not taken.
2461224 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8812
2/2
✓ Branch 0 taken 2461199 times.
✓ Branch 1 taken 19 times.
2461218 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8813 72005040 return true;
8814
8815 2461199 return false;
8816 9284885 }
8817
8818 149218771 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8819 {
8820 149218771 bool ret = false, drunkstate = false, rawret = false;;
8821 149218771 bool* flag = &down_control_states[btn];
8822
2/7
✓ Branch 0 taken 139924550 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9294221 times.
149218771 switch(btn)
8823 {
8824 case btnF12:
8825 ret = zc_getkey(KEY_F12, ignoreDisable);
8826 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8827 eatEntirely = false;
8828 break;
8829 case btnF11:
8830 ret = zc_getkey(KEY_F11, ignoreDisable);
8831 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8832 eatEntirely = false;
8833 break;
8834 case btnF5:
8835 ret = zc_getkey(KEY_F5, ignoreDisable);
8836 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8837 eatEntirely = false;
8838 break;
8839 case btnQ:
8840 ret = zc_getkey(KEY_Q, ignoreDisable);
8841 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8842 eatEntirely = false;
8843 break;
8844 case btnI:
8845 ret = zc_getkey(KEY_I, ignoreDisable);
8846 rawret = zc_getrawkey(KEY_I, ignoreDisable);
8847 eatEntirely = false;
8848 break;
8849 case btnM:
8850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9294221 times.
9294221 if(FFCore.kb_typing_mode) return false;
8851 9294221 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8852 9294221 eatEntirely = false;
8853 9294221 break;
8854 default: //control_state[] index
8855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139924550 times.
139924550 if(FFCore.kb_typing_mode) return false;
8856
5/6
✓ Branch 0 taken 139125093 times.
✓ Branch 1 taken 799457 times.
✓ Branch 2 taken 2190312 times.
✓ Branch 3 taken 136934781 times.
✓ Branch 4 taken 2190312 times.
✗ Branch 5 not taken.
139924550 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8857
2/2
✓ Branch 0 taken 7643659 times.
✓ Branch 1 taken 132280891 times.
139924550 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8858
4/4
✓ Branch 0 taken 125762876 times.
✓ Branch 1 taken 14161674 times.
✓ Branch 2 taken 2995 times.
✓ Branch 3 taken 14158679 times.
154086224 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8859 139924550 rawret = raw_control_state[btn];
8860 139924550 }
8861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149218771 times.
149218771 assert(flag);
8862
2/2
✓ Branch 0 taken 95660512 times.
✓ Branch 1 taken 53558259 times.
149218771 if(press)
8863 {
8864
2/2
✓ Branch 0 taken 1846969 times.
✓ Branch 1 taken 51711290 times.
53558259 if(peek)
8865 1846969 ret = rButtonPeek(ret, *flag);
8866
2/2
✓ Branch 0 taken 50512842 times.
✓ Branch 1 taken 1198448 times.
51711290 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
8867 1198448 else ret = rButton(ret, *flag, rawret);
8868 53558259 }
8869
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 149218771 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
149218771 if(eatEntirely && ret) control_state[btn] = false;
8870
3/4
✓ Branch 0 taken 112177235 times.
✓ Branch 1 taken 37041536 times.
✓ Branch 2 taken 112177235 times.
✗ Branch 3 not taken.
149218771 if(drunk && drunkstate) ret = !ret;
8871 149218771 return ret;
8872 149218771 }
8873
8874 7333004 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8875 {
8876 7333004 byte ret = 0;
8877
2/2
✓ Branch 0 taken 5483936 times.
✓ Branch 1 taken 1849068 times.
7333004 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
8878
2/2
✓ Branch 0 taken 7332442 times.
✓ Branch 1 taken 562 times.
7333004 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
8879
2/2
✓ Branch 0 taken 7332567 times.
✓ Branch 1 taken 437 times.
7333004 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
8880
2/2
✓ Branch 0 taken 7332567 times.
✓ Branch 1 taken 437 times.
7333004 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
8881
2/2
✓ Branch 0 taken 7332567 times.
✓ Branch 1 taken 437 times.
7333004 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
8882
2/2
✓ Branch 0 taken 7332567 times.
✓ Branch 1 taken 437 times.
7333004 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
8883
2/2
✓ Branch 0 taken 7332567 times.
✓ Branch 1 taken 437 times.
7333004 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
8884
2/2
✓ Branch 0 taken 7332567 times.
✓ Branch 1 taken 437 times.
7333004 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
8885 7333004 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
8886 }
8887
8888 1114 byte checkIntBtnVal(byte intbtn, byte vals)
8889 {
8890 1114 return intbtn&vals;
8891 }
8892
8893 1767241 bool Up()
8894 {
8895 1767241 return getInput(btnUp);
8896 }
8897 146943 bool Down()
8898 {
8899 146943 return getInput(btnDown);
8900 }
8901 257358 bool Left()
8902 {
8903 257358 return getInput(btnLeft);
8904 }
8905 286551 bool Right()
8906 {
8907 286551 return getInput(btnRight);
8908 }
8909 164908 bool cAbtn()
8910 {
8911 164908 return getInput(btnA);
8912 }
8913 1411891 bool cBbtn()
8914 {
8915 1411891 return getInput(btnB);
8916 }
8917 bool cSbtn()
8918 {
8919 return getInput(btnS);
8920 }
8921 68744 bool cLbtn()
8922 {
8923 68744 return getInput(btnL);
8924 }
8925 68744 bool cRbtn()
8926 {
8927 68744 return getInput(btnR);
8928 }
8929 bool cPbtn()
8930 {
8931 return getInput(btnP);
8932 }
8933 bool cEx1btn()
8934 {
8935 return getInput(btnEx1);
8936 }
8937 bool cEx2btn()
8938 {
8939 return getInput(btnEx2);
8940 }
8941 bool cEx3btn()
8942 {
8943 return getInput(btnEx3);
8944 }
8945 bool cEx4btn()
8946 {
8947 return getInput(btnEx4);
8948 }
8949 bool AxisUp()
8950 {
8951 return getInput(btnAxisUp);
8952 }
8953 bool AxisDown()
8954 {
8955 return getInput(btnAxisDown);
8956 }
8957 bool AxisLeft()
8958 {
8959 return getInput(btnAxisLeft);
8960 }
8961 bool AxisRight()
8962 {
8963 return getInput(btnAxisRight);
8964 }
8965
8966 bool cMbtn()
8967 {
8968 return getInput(btnM);
8969 }
8970 bool cF12()
8971 {
8972 return getInput(btnF12);
8973 }
8974 bool cF11()
8975 {
8976 return getInput(btnF11);
8977 }
8978 bool cF5()
8979 {
8980 return getInput(btnF5);
8981 }
8982 bool cQ()
8983 {
8984 return getInput(btnQ);
8985 }
8986 bool cI()
8987 {
8988 return getInput(btnI);
8989 }
8990
8991 130270 bool rUp()
8992 {
8993 130270 return getInput(btnUp, true);
8994 }
8995 130174 bool rDown()
8996 {
8997 130174 return getInput(btnDown, true);
8998 }
8999 130122 bool rLeft()
9000 {
9001 130122 return getInput(btnLeft, true);
9002 }
9003 129657 bool rRight()
9004 {
9005 129657 return getInput(btnRight, true);
9006 }
9007 3145 bool rAbtn()
9008 {
9009 3145 return getInput(btnA, true);
9010 }
9011 131548 bool rBbtn()
9012 {
9013 131548 return getInput(btnB, true);
9014 }
9015 7395150 bool rSbtn()
9016 {
9017 7395150 return getInput(btnS, true);
9018 }
9019 9284885 bool rMbtn()
9020 {
9021 9284885 return getInput(btnM, true);
9022 }
9023 129441 bool rLbtn()
9024 {
9025 129441 return getInput(btnL, true);
9026 }
9027 129436 bool rRbtn()
9028 {
9029 129436 return getInput(btnR, true);
9030 }
9031 7331614 bool rPbtn()
9032 {
9033 7331614 return getInput(btnP, true);
9034 }
9035 bool rEx1btn()
9036 {
9037 return getInput(btnEx1, true);
9038 }
9039 bool rEx2btn()
9040 {
9041 return getInput(btnEx2, true);
9042 }
9043 140087 bool rEx3btn()
9044 {
9045 140087 return getInput(btnEx3, true);
9046 }
9047 140087 bool rEx4btn()
9048 {
9049 140087 return getInput(btnEx4, true);
9050 }
9051 bool rAxisUp()
9052 {
9053 return getInput(btnAxisUp, true);
9054 }
9055 bool rAxisDown()
9056 {
9057 return getInput(btnAxisDown, true);
9058 }
9059 bool rAxisLeft()
9060 {
9061 return getInput(btnAxisLeft, true);
9062 }
9063 bool rAxisRight()
9064 {
9065 return getInput(btnAxisRight, true);
9066 }
9067
9068 bool rF11()
9069 {
9070 return getInput(btnF11, true);
9071 }
9072 bool rQ()
9073 {
9074 return getInput(btnQ, true);
9075 }
9076 bool rI()
9077 {
9078 return getInput(btnI, true);
9079 }
9080
9081 18221761 bool DrunkUp()
9082 {
9083 18221761 return getInput(btnUp, false, true);
9084 }
9085 16885096 bool DrunkDown()
9086 {
9087 16885096 return getInput(btnDown, false, true);
9088 }
9089 10286362 bool DrunkLeft()
9090 {
9091 10286362 return getInput(btnLeft, false, true);
9092 }
9093 8832529 bool DrunkRight()
9094 {
9095 8832529 return getInput(btnRight, false, true);
9096 }
9097 8034060 bool DrunkcAbtn()
9098 {
9099 8034060 return getInput(btnA, false, true);
9100 }
9101 7848589 bool DrunkcBbtn()
9102 {
9103 7848589 return getInput(btnB, false, true);
9104 }
9105 7262484 bool DrunkcEx1btn()
9106 {
9107 7262484 return getInput(btnEx1, false, true);
9108 }
9109 7262504 bool DrunkcEx2btn()
9110 {
9111 7262504 return getInput(btnEx2, false, true);
9112 }
9113 bool DrunkcSbtn()
9114 {
9115 return getInput(btnS, false, true);
9116 }
9117 bool DrunkcMbtn()
9118 {
9119 return getInput(btnM, false, true);
9120 }
9121 bool DrunkcLbtn()
9122 {
9123 return getInput(btnL, false, true);
9124 }
9125 bool DrunkcRbtn()
9126 {
9127 return getInput(btnR, false, true);
9128 }
9129 bool DrunkcPbtn()
9130 {
9131 return getInput(btnP, false, true);
9132 }
9133
9134 bool DrunkrUp()
9135 {
9136 return getInput(btnUp, true, true);
9137 }
9138 bool DrunkrDown()
9139 {
9140 return getInput(btnDown, true, true);
9141 }
9142 bool DrunkrLeft()
9143 {
9144 return getInput(btnLeft, true, true);
9145 }
9146 bool DrunkrRight()
9147 {
9148 return getInput(btnRight, true, true);
9149 }
9150 6080189 bool DrunkrAbtn()
9151 {
9152 6080189 return getInput(btnA, true, true);
9153 }
9154 6097021 bool DrunkrBbtn()
9155 {
9156 6097021 return getInput(btnB, true, true);
9157 }
9158 71669 bool DrunkrEx1btn()
9159 {
9160 71669 return getInput(btnEx1, true, true);
9161 }
9162 71662 bool DrunkrEx2btn()
9163 {
9164 71662 return getInput(btnEx2, true, true);
9165 }
9166 bool DrunkrEx3btn()
9167 {
9168 return getInput(btnEx3, true, true);
9169 }
9170 bool DrunkrEx4btn()
9171 {
9172 return getInput(btnEx4, true, true);
9173 }
9174 bool DrunkrSbtn()
9175 {
9176 return getInput(btnS, true, true);
9177 }
9178 bool DrunkrMbtn()
9179 {
9180 return getInput(btnM, true, true);
9181 }
9182 6687266 bool DrunkrLbtn()
9183 {
9184 6687266 return getInput(btnL, true, true);
9185 }
9186 6683791 bool DrunkrRbtn()
9187 {
9188 6683791 return getInput(btnR, true, true);
9189 }
9190 bool DrunkrPbtn()
9191 {
9192 return getInput(btnP, true, true);
9193 }
9194
9195 9336 void eat_buttons()
9196 {
9197 9336 getInput(btnA, true, false, true);
9198 9336 getInput(btnB, true, false, true);
9199 9336 getInput(btnS, true, false, true);
9200 9336 getInput(btnM, true, false, true);
9201 9336 getInput(btnL, true, false, true);
9202 9336 getInput(btnR, true, false, true);
9203 9336 getInput(btnP, true, false, true);
9204 9336 getInput(btnEx1, true, false, true);
9205 9336 getInput(btnEx2, true, false, true);
9206 9336 getInput(btnEx3, true, false, true);
9207 9336 getInput(btnEx4, true, false, true);
9208 9336 }
9209
9210 // Is true for the _first frame_ of a key press.
9211 // But! it is possible that a script manually sets the value of KeyPress,
9212 // in which case it will be restored to the "true" value based on `key_current_frame`
9213 // and `key_previous_frame` on the next frame.
9214 13 bool zc_readkey(int32_t k, bool ignoreDisable)
9215 {
9216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(ignoreDisable) return KeyPress[k];
9217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 switch(k)
9218 {
9219 case KEY_F7:
9220 case KEY_F8:
9221 case KEY_F9:
9222 return KeyPress[k];
9223
9224 default:
9225
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 return KeyPress[k] && !disabledKeys[k];
9226 }
9227 13 }
9228
9229 // Is true for _every frame_ a key is held down.
9230 // But! it is possible that a script manually sets the value of KeyInput,
9231 // in which case it will be restored to the "true" value based on `key_current_frame`
9232 // on the next frame.
9233 bool zc_getkey(int32_t k, bool ignoreDisable)
9234 {
9235 if(ignoreDisable) return KeyInput[k];
9236 switch(k)
9237 {
9238 case KEY_F7:
9239 case KEY_F8:
9240 case KEY_F9:
9241 return KeyInput[k];
9242
9243 default:
9244 return KeyInput[k] && !disabledKeys[k];
9245 }
9246 }
9247
9248 // Reads (and then clears) the current frame key state directly.
9249 // Scripts can also modify `key_current_frame`.
9250 300 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9251 {
9252
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 298 times.
300 if(zc_getrawkey(k, ignoreDisable))
9253 {
9254 2 _key[k]=key[k]=key_current_frame[k]=0;
9255 2 return true;
9256 }
9257 298 _key[k]=key[k]=key_current_frame[k]=0;
9258 298 return false;
9259 300 }
9260
9261 // Reads the current frame key state directly.
9262 // Scripts can also modify `key_current_frame`.
9263 63237898 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9264 {
9265
2/2
✓ Branch 0 taken 53952987 times.
✓ Branch 1 taken 9284911 times.
63237898 if(ignoreDisable) return key_current_frame[k];
9266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284911 times.
9284911 switch(k)
9267 {
9268 case KEY_F7:
9269 case KEY_F8:
9270 case KEY_F9:
9271 return key_current_frame[k];
9272
9273 default:
9274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284911 times.
9284911 return key_current_frame[k] && !disabledKeys[k];
9275 }
9276 63237898 }
9277
9278 // Only used for a handful of keys, like tilde and Function keys.
9279 // This state is never read within the game.
9280 // It exists so that all keyboard input still functions during replay,
9281 // without inadvertently doing things like toggling throttling if the player
9282 // presses ~
9283 9284885 bool zc_get_system_key(int32_t k)
9284 {
9285 9284885 return key_system[k];
9286 }
9287
9288 // True for the _first_ frame of a key press.
9289 83563965 bool zc_read_system_key(int32_t k)
9290 {
9291 83563965 return key_system_press[k];
9292 }
9293
9294 1179180395 bool is_system_key(int32_t k)
9295 {
9296
2/2
✓ Branch 0 taken 1095616430 times.
✓ Branch 1 taken 83563965 times.
1179180395 switch (k)
9297 {
9298 case KEY_BACKQUOTE:
9299 case KEY_CLOSEBRACE:
9300 case KEY_END:
9301 case KEY_HOME:
9302 case KEY_OPENBRACE:
9303 case KEY_PGDN:
9304 case KEY_PGUP:
9305 case KEY_TAB:
9306 case KEY_TILDE:
9307 83563965 return true;
9308 }
9309 1095616430 return is_Fkey(k);
9310 1179180395 }
9311
9312 9284885 void update_system_keys()
9313 {
9314
2/2
✓ Branch 0 taken 1179180395 times.
✓ Branch 1 taken 9284885 times.
1188465280 for (int32_t q = 0; q < 127; ++q)
9315 {
9316
2/2
✓ Branch 0 taken 194982585 times.
✓ Branch 1 taken 984197810 times.
1179180395 if (!is_system_key(q))
9317 984197810 continue;
9318
9319 194982585 key_system[q] = key[q];
9320
1/2
✓ Branch 0 taken 194982585 times.
✗ Branch 1 not taken.
194982585 key_system_press[q] = key_system[q] && !key_system_previous[q];
9321 194982585 key_system_previous[q] = key_system[q];
9322 194982585 }
9323 9284885 }
9324
9325 10389172 void update_keys()
9326 {
9327
2/2
✓ Branch 0 taken 1319424844 times.
✓ Branch 1 taken 10389172 times.
1329814016 for (int32_t q = 0; q < 127; ++q)
9328 {
9329 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9330
1/2
✓ Branch 0 taken 1319424844 times.
✗ Branch 1 not taken.
1319424844 if (!replay_is_replaying())
9331 key_current_frame[q] = key[q];
9332
9333
2/2
✓ Branch 0 taken 1309638469 times.
✓ Branch 1 taken 9786375 times.
1319424844 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9334 1319424844 KeyInput[q] = key_current_frame[q];
9335 1319424844 key_previous_frame[q] = key_current_frame[q];
9336 1319424844 }
9337 10389172 }
9338
9339 bool zc_disablekey(int32_t k, bool val)
9340 {
9341 switch(k)
9342 {
9343 case KEY_F7:
9344 case KEY_F8:
9345 case KEY_F9:
9346 return false;
9347
9348 default:
9349 disabledKeys[k] = val;
9350 return true;
9351 }
9352 }
9353
9354 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9355 {
9356 timer=timer;
9357 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9358 }
9359